From 0f647e57cb27030670c9b23ca83184535944c274 Mon Sep 17 00:00:00 2001 From: wuzihao051119 Date: Wed, 16 Jul 2025 21:26:54 +0800 Subject: [PATCH] remove ref listen and global key --- .../bottom_sheet/map_bottom_sheet.widget.dart | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/mobile/lib/presentation/widgets/bottom_sheet/map_bottom_sheet.widget.dart b/mobile/lib/presentation/widgets/bottom_sheet/map_bottom_sheet.widget.dart index e5b7a0ee67..006f6d268b 100644 --- a/mobile/lib/presentation/widgets/bottom_sheet/map_bottom_sheet.widget.dart +++ b/mobile/lib/presentation/widgets/bottom_sheet/map_bottom_sheet.widget.dart @@ -6,25 +6,13 @@ import 'package:immich_mobile/presentation/widgets/timeline/timeline.widget.dart import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart'; import 'package:maplibre_gl/maplibre_gl.dart'; -class MapBottomSheet extends ConsumerStatefulWidget { +class MapBottomSheet extends ConsumerWidget { const MapBottomSheet({super.key}); @override - ConsumerState createState() => _MapBottomSheetState(); -} - -class _MapBottomSheetState extends ConsumerState { - GlobalKey key = GlobalKey(); - - @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { LatLngBounds bounds = ref.watch(mapStateProvider.select((s) => s.bounds)); - ref.listen(mapStateProvider, (previous, next) async { - bounds = next.bounds; - key = GlobalKey(); - }); - return BaseBottomSheet( initialChildSize: 0.25, shouldCloseOnMinExtent: false, @@ -32,7 +20,7 @@ class _MapBottomSheetState extends ConsumerState { slivers: [ SliverFillRemaining( child: ProviderScope( - key: key, + key: ObjectKey(bounds), overrides: [ timelineServiceProvider.overrideWith((ref) { final timelineService =