我在物理Android设备(Oneplus 6t)上使用了官方的google_maps_flutter插件,自从上次Flutter升级以来,我在调用GoogleMap小部件时出现黑屏。我目前在master分支上。任何帮助将不胜感激,谢谢。
插件版本 google_maps_flutter:^ 0.0.3 + 3
要复制的代码
_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;
日志: java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法'double java.lang.Double.doubleValue()' E / MethodChannel#flutter / platform_views(29682):位于io.flutter.plugin.platform.PlatformViewsController.createPlatformView(PlatformViewsController.java:141) E / MethodChannel#flutter / platform_views(29682):位于io.flutter.plugin.platform.PlatformViewsController.onMethodCall(PlatformViewsController.java:118) E / MethodChannel#flutter / platform_views(29682):位于io.flutter.plugin.common.MethodChannel $ IncomingMethodCallHandler.onMessage(MethodChannel.java:200) E / MethodChannel#flutter / platform_views(29682):位于io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163) E / MethodChannel#flutter / platform_views(29682):位于android.os.MessageQueue.nativePollOnce(本机方法) E / MethodChannel#flutter / platform_views(29682):位于android.os.MessageQueue.next(MessageQueue.java:326) E / MethodChannel#flutter / platform_views(29682):位于android.os.Looper.loop(Looper.java:160) E / MethodChannel#flutter / platform_views(29682):位于android.app.ActivityThread.main(ActivityThread.java:6863) E / MethodChannel#flutter / platform_views(29682):位于java.lang.reflect.Method.invoke(本机方法) E / MethodChannel#flutter / platform_views(29682):at com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:537) E / MethodChannel#flutter / platform_views(29682):位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
答案 0 :(得分:0)
我有一个类似的问题,但通过替换为地图视图的“容器扩展”得到了解决