Search code examples
androidfluttergoogle-mapsadb

Flutter Google Maps white screen bug on Android


This issue has been driving me crazy. On our app for over a year now, we have had a glitch with google maps on Android. We cannot actively reproduce it, and it happens at completely different and random times, doesn’t matter if the app has been backgrounded or not. The issue is that the whole map sometimes appears as a blank white screen. To fix the issue, you will have to switch between the layers a couple of times and then the map will reappear as normal. We managed to reproduce it with this command once.

adb shell am send-trim-memory BUNDLEID COMPLETE

However, it doesnt give us much information. Has anybody every experienced this before?enter image description here


Solution

  • To anyone having this issue, we have finally managed to fix it by doing this.

        @override
          void didChangeAppLifecycleState(AppLifecycleState state) {
            if (Platform.isAndroid && state == AppLifecycleState.resumed) {
              setState(() {
                _controller.forceReRender();
              });
            }
            super.didChangeAppLifecycleState(state);
          }
    
          Future<void> forceReRender() async {
           await _mapController?.setMapStyle('[]');
          }
    

    So we force a re-render of the Map Style whenever the app is resumed. We have only seen this on Androids so we also check if it is an Android phone to avoid unnecessary re-rendering on iOS.