From 7f180664dc2deaf2c8dc56758fb7065edd21100b Mon Sep 17 00:00:00 2001 From: kaushik Date: Mon, 17 Jun 2024 16:07:35 +0530 Subject: [PATCH] Fix map dark and light mode style --- app/lib/ui/flow/home/map/map_view.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/lib/ui/flow/home/map/map_view.dart b/app/lib/ui/flow/home/map/map_view.dart index 412bdf6f..108afafc 100644 --- a/app/lib/ui/flow/home/map/map_view.dart +++ b/app/lib/ui/flow/home/map/map_view.dart @@ -57,6 +57,7 @@ class _MapScreenState extends ConsumerState { notifier = ref.watch(mapViewStateProvider.notifier); final state = ref.watch(mapViewStateProvider); + _updateMapStyle(context.brightness == Brightness.dark); return Stack( children: [ Center( @@ -101,6 +102,17 @@ class _MapScreenState extends ConsumerState { _controller.complete(controller); } + void _updateMapStyle(bool isDarkMode) async { + final controller = await _controller.future; + if (isDarkMode) { + final style = + await rootBundle.loadString('assets/map/map_theme_night.json'); + controller.setMapStyle(style); + } else { + controller.setMapStyle(null); + } + } + void _observeMapCameraPosition() { ref.listen(mapViewStateProvider.select((state) => state.defaultPosition), (previous, next) async {