From 22fef0e0a8f66cdf2f2153b2e9dd6fb23787550d Mon Sep 17 00:00:00 2001 From: anhtunz Date: Mon, 9 Jun 2025 15:43:50 +0700 Subject: [PATCH] fix map --- lib/feature/main/main_screen.dart | 9 --------- lib/feature/map/map_screen.dart | 17 ++++++++++------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/lib/feature/main/main_screen.dart b/lib/feature/main/main_screen.dart index 9c641d9..a7ed8a2 100644 --- a/lib/feature/main/main_screen.dart +++ b/lib/feature/main/main_screen.dart @@ -194,15 +194,6 @@ class _MainScreenState extends State with WidgetsBindingObserver { inactiveIcon: IconConstants.instance.getMaterialIcon(Icons.group_outlined), ), - // PersistentBottomNavBarItem( - // icon: IconConstants.instance - // .getMaterialIcon(Icons.notifications_outlined), - // title: appLocalization(context).notification, - // activeColorPrimary: Colors.blue, - // inactiveColorPrimary: Colors.grey, - // inactiveIcon: IconConstants.instance - // .getMaterialIcon(Icons.notifications_outlined), - // ), ]; } diff --git a/lib/feature/map/map_screen.dart b/lib/feature/map/map_screen.dart index 6a798fe..cafcb55 100644 --- a/lib/feature/map/map_screen.dart +++ b/lib/feature/map/map_screen.dart @@ -59,6 +59,7 @@ class _MapScreenState extends State with WidgetsBindingObserver { Timer? checkThemeTimer; Timer? getMarker; String themeMode = ''; + bool _isDisposed = false; @override void initState() { super.initState(); @@ -74,18 +75,20 @@ class _MapScreenState extends State with WidgetsBindingObserver { @override void dispose() { + _isDisposed = true; checkThemeTimer?.cancel(); getMarker?.cancel(); - _controller = Completer(); streamController.close(); super.dispose(); } void onMapCreated(GoogleMapController controller) { - _controller.complete(controller); - streamController.add(controller); - clusterManager.setMapId(controller.mapId); - checkTheme(); + if (!_isDisposed && !streamController.isClosed) { + _controller.complete(controller); + streamController.add(controller); + clusterManager.setMapId(controller.mapId); + checkTheme(); + } } @override @@ -173,11 +176,11 @@ class _MapScreenState extends State with WidgetsBindingObserver { return ClusterManager( devices, _updateMarkers, - markerBuilder: _getmarkerBuilder(), + markerBuilder: _getMarkerBuilder(), ); } - Future Function(Cluster) _getmarkerBuilder() => + Future Function(Cluster) _getMarkerBuilder() => (cluster) async { return Marker( markerId: MarkerId(