diff --git a/mobile/lib/presentation/widgets/map/map.widget.dart b/mobile/lib/presentation/widgets/map/map.widget.dart index 78c3f9f46a..c72262604a 100644 --- a/mobile/lib/presentation/widgets/map/map.widget.dart +++ b/mobile/lib/presentation/widgets/map/map.widget.dart @@ -128,6 +128,20 @@ class _DriftMapState extends ConsumerState { @override Widget build(BuildContext context) { + final bounds = ref.watch(mapStateProvider.select((s) => s.bounds)); + AsyncValue> markers = + ref.watch(mapMarkerProvider(bounds)); + AsyncValue> allMarkers = + ref.watch(mapMarkerProvider(null)); + + ref.listen(mapStateProvider, (previous, next) async { + markers = ref.watch(mapMarkerProvider(bounds)); + }); + + markers.whenData((markers) => reloadMarkers(markers)); + allMarkers + .whenData((markers) => reloadMarkers(markers, isLoadAllMarkers: true)); + return Stack( children: [ _Map( @@ -135,9 +149,7 @@ class _DriftMapState extends ConsumerState { onMapMoved: onMapMoved, ), _MyLocationButton(onZoomToLocation: onZoomToLocation), - _Markers( - reloadMarkers: reloadMarkers, - ), + const MapBottomSheet(), ], ); } @@ -170,31 +182,6 @@ class _Map extends StatelessWidget { } } -class _Markers extends ConsumerWidget { - const _Markers({required this.reloadMarkers}); - - final Function(Map, {bool isLoadAllMarkers}) reloadMarkers; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final bounds = ref.watch(mapStateProvider.select((s) => s.bounds)); - AsyncValue> markers = - ref.watch(mapMarkerProvider(bounds)); - AsyncValue> allMarkers = - ref.watch(mapMarkerProvider(null)); - - ref.listen(mapStateProvider, (previous, next) async { - markers = ref.watch(mapMarkerProvider(bounds)); - }); - - markers.whenData((markers) => reloadMarkers(markers)); - allMarkers - .whenData((markers) => reloadMarkers(markers, isLoadAllMarkers: true)); - - return const MapBottomSheet(); - } -} - class _MyLocationButton extends StatelessWidget { const _MyLocationButton({required this.onZoomToLocation});