Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix gallery files exception during AnimatedCrossFade early build

ashilkn6b0ba1543071
diff --git a/mobile/apps/photos/lib/ui/viewer/actions/file_selection_overlay_bar.dart b/mobile/apps/photos/lib/ui/viewer/actions/file_selection_overlay_bar.dart
index bdf23c1b2b..90b1727176 100644
--- a/mobile/apps/photos/lib/ui/viewer/actions/file_selection_overlay_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/actions/file_selection_overlay_bar.dart
@@ -257,7 +257,10 @@ class _SelectAllButtonState extends State<SelectAllButton> {
@override
Widget build(BuildContext context) {
final selectionState = SelectionState.of(context);
- final allGalleryFiles = GalleryFilesState.of(context).galleryFiles;
+ final allGalleryFiles = GalleryFilesState.of(context).galleryFilesOrNull;
+ if (allGalleryFiles == null) {
+ return const SizedBox.shrink();
+ }
assert(
selectionState != null,
"SelectionState not found in context, SelectionState should be an ancestor of FileSelectionOverlayBar",
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/state/gallery_files_inherited_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/state/gallery_files_inherited_widget.dart
index bd07d93309..9a91c82ac3 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/state/gallery_files_inherited_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/state/gallery_files_inherited_widget.dart
@@ -22,12 +22,13 @@ class GalleryFilesState extends InheritedWidget {
_galleryFiles!.remove(file);
}
+ List<EnteFile>? get galleryFilesOrNull => _galleryFiles;
+
List<EnteFile> get galleryFiles {
- if (_galleryFiles == null) {
- throw Exception(
- "Gallery files not set yet. Should be set in the gallery widget",
- );
- }
+ assert(
+ _galleryFiles != null,
+ "Gallery files not set yet. Should be set in the gallery widget",
+ );
return _galleryFiles!;
}