0
votes

I'm using the official google_maps_flutter plugin on a physical Android device (Oneplus 6t) and since last Flutter upgrade I'm getting black screen when calling GoogleMap widget. I'm currently on the master branch. Any help would be really appreciated, thank you.

Plugin version google_maps_flutter: ^0.0.3+3

Code to Reproduce

_buildScaffold(LatLng position){
Scaffold s = new Scaffold(
key: _scaffoldKey,
appBar: buildAppBar(context),
resizeToAvoidBottomPadding: false,

body:
new Padding(
  padding: new EdgeInsets.all(8.0),
  child: widget.viewSwitchManager.mapView
      ? new Column(
    children: [
      new Flexible(
          child: new Stack(
              children: <Widget>[
            google_maps.GoogleMap(
              onMapCreated: _onMapCreated,

             options: google_maps.GoogleMapOptions(
                mapType: google_maps.MapType.normal,
                myLocationEnabled: true,
                cameraPosition: google_maps.CameraPosition(
                  target: google_maps.LatLng(position.latitude, 
   position.longitude),
                  zoom: 11.0,
                ),

              ),
            ),


            _showFloatingMapListButton(),
            _showFloatingFiltersButton(),

           ]))
      ],
     )
       :
    Stack(
        children: <Widget>[
        events != null ?
        new Swiper(
          loop: false,
          itemBuilder: (BuildContext context, int index) {
            EventTheTableLight event = events[index];
            return EventSwiperCard(event: event);
          },
          itemCount: events.length,
          viewportFraction: 0.8,
          scale: 0.9,
        ) : SizedBox(),
        _showFloatingMapListButton(),
        _showFloatingFiltersButton(),
      ])


   ),

   /*bottomNavigationBar: BottomAppBar(
  child: new Row(
  mainAxisSize: MainAxisSize.max,
  mainAxisAlignment: MainAxisAlignment.spaceBetween,
  children: <Widget>[
    IconButton(
        icon: Icon(Icons.filter_list),
        onPressed: () {
          _filtersBottomSheet();
    }),
    SizedBox(width: MediaQuery.of(context).size.width/1.8,),
    IconButton(
        icon: Icon(Icons.refresh),
        onPressed: () {
      refreshEvents();
    }),

    ],
    ),
  ),*/
  );
  if(widget.viewSwitchManager.mapView && gMapController != null) {
  _buildMarkers(position);
  gMapController.onMarkerTapped.add(_onMarkerTapped);
  }
   //if (!_searched)
  //_updateMapCenter(position, 13.0);
   return s;

LOG: java.lang.NullPointerException: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference E/MethodChannel#flutter/platform_views(29682): at io.flutter.plugin.platform.PlatformViewsController.createPlatformView(PlatformViewsController.java:141) E/MethodChannel#flutter/platform_views(29682): at io.flutter.plugin.platform.PlatformViewsController.onMethodCall(PlatformViewsController.java:118) E/MethodChannel#flutter/platform_views(29682): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200) E/MethodChannel#flutter/platform_views(29682): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163) E/MethodChannel#flutter/platform_views(29682): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#flutter/platform_views(29682): at android.os.MessageQueue.next(MessageQueue.java:326) E/MethodChannel#flutter/platform_views(29682): at android.os.Looper.loop(Looper.java:160) E/MethodChannel#flutter/platform_views(29682): at android.app.ActivityThread.main(ActivityThread.java:6863) E/MethodChannel#flutter/platform_views(29682): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#flutter/platform_views(29682): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537) E/MethodChannel#flutter/platform_views(29682): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

1
If you've been staring at this for now 3 hours, you've probably looked into this already, but I would check if position or position.latitude/longitude are null. Dart decimals are doubles in java and your trace is suggesting a null Double... - Rob C
Unfortunately yes, lat and lon are not null, but I think the problem is that TargetPlatform, in some way, is set to iOS.... I'll keep on investigating on that and write back any potential fix - Melvin
Workaround (or, at least, something similar): if(LocalPlatform().isAndroid) debugDefaultTargetPlatformOverride = TargetPlatform.android; else debugDefaultTargetPlatformOverride = TargetPlatform.iOS; - Melvin

1 Answers

0
votes

I have a similar issue but it got solved by replacing Expanded by Container for Map view