This error happen only when tested flutter app on my huawei p10+. My app load googlemap on an alertdialog. Map can load a few times and then it fail randomly. But i noticed Googlemap unable to load in the alertdialog container when it fail. This is my code:
_loadMapDialog() {
try {
if (_currentPosition.latitude == null) {
Toast.show("Location not available. Please wait...", context,
duration: Toast.LENGTH_LONG, gravity: Toast.BOTTOM);
_getLocation(); //_getCurrentLocation();
return;
}
_controller = Completer();
_userpos = CameraPosition(
target: LatLng(latitude, longitude),
zoom: 14.4746,
);
markers.add(Marker(
markerId: markerId1,
position: LatLng(latitude, longitude),
infoWindow: InfoWindow(
title: 'Current Location',
snippet: 'Delivery Location',
)));
showDialog(
context: context,
builder: (context) {
return StatefulBuilder(
builder: (context, newSetState) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0))),
title: Text("Select Your Location"),
titlePadding: EdgeInsets.all(5),
//content: Text(curaddress),
actions: <Widget>[
Text(curaddress),
Container(
height: screenHeight / 2 ?? 600,
width: screenWidth ?? 360,
child: GoogleMap(
mapType: MapType.normal,
initialCameraPosition: _userpos,
markers: markers.toSet(),
onMapCreated: (controller) {
_controller.complete(controller);
},
onTap: (newLatLng) {
_loadLoc(newLatLng, newSetState);
}),
),
MaterialButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0)),
//minWidth: 200,
height: 30,
child: Text('Close'),
color: Colors.blue[500],
textColor: Colors.white,
elevation: 10,
onPressed: () =>
{markers.clear(), Navigator.of(context).pop(false)},
),
],
);
},
);
},
);
} catch (e) {
print(e);
return;
}
}
Debug console produce the following error
D/mali_winsys(10015): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
I/HiTouch_HiTouchSensor(10015): HiTouch restricted: Sub windows restricted.
D/HiTouch_PressGestureDetector(10015): onAttached, package=com.slumberjer.myappt, windowType=2037, mHiTouchRestricted=true
D/mali_winsys(10015): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/mali_winsys(10015): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
W/libEGL (10015): EGLNativeWindowType 0x6ff5f79010 disconnect failed
D/mali_winsys(10015): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/AndroidRuntime( 9587): Shutting down VM
E/AndroidRuntime( 9587): FATAL EXCEPTION: main
E/AndroidRuntime( 9587): Process: com.slumberjer.myappt, PID: 9587
E/AndroidRuntime( 9587): java.lang.NullPointerException: Attempt to invoke virtual method
'android.view.DisplayAdjustments android.view.Display.getDisplayAdjustments()' on a null object reference
E/AndroidRuntime( 9587): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1636)
E/AndroidRuntime( 9587): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7946)
E/AndroidRuntime( 9587): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1092)
E/AndroidRuntime( 9587): at android.view.Choreographer.doCallbacks(Choreographer.java:893)
E/AndroidRuntime( 9587): at android.view.Choreographer.doFrame(Choreographer.java:812)
E/AndroidRuntime( 9587): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1078)
E/AndroidRuntime( 9587): at android.os.Handler.handleCallback(Handler.java:907)
E/AndroidRuntime( 9587): at android.os.Handler.dispatchMessage(Handler.java:105)
E/AndroidRuntime( 9587): at android.os.Looper.loop(Looper.java:216)
E/AndroidRuntime( 9587): at android.app.ActivityThread.main(ActivityThread.java:7625)
E/AndroidRuntime( 9587): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 9587): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
E/AndroidRuntime( 9587): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
W/System ( 9587): A resource failed to call release.
I/Process ( 9587): Sending signal. PID: 9587 SIG: 9
Lost connection to device.
Exited (sigterm)
Tested the same code on different devices other than Huawei phone seems to work just fine. Is there any workaround if this error seems to be device dependent.