我正试图根据我的云火库中保存的位置在地图上获取标记我写了一个关于媒体的教程-Flutter中的谷歌地图我在Navigator.push((调用以下类时出现此错误
// to implememnt
import 'dart:async';
//import 'dart:html';
import 'package:basicSignIn/Global/color.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
class MapShopPicker extends StatefulWidget {
@override
_MapShopPickerState createState() => _MapShopPickerState();
}
var pposition;
var shopChosenValue = null;
class _MapShopPickerState extends State<MapShopPicker> {
Completer<GoogleMapController> _controller = Completer();
String _locationMessage = "";
void _getCurrentLocation() async {
final position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
print(position);
pposition = position;
setState(() {
pposition = position;
_locationMessage = "${position.latitude}, ${position.longitude}";
});
}
@override
void initState() {
_getCurrentLocation();
getClients();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
actions: <Widget>[
FlatButton(onPressed: _getCurrentLocation, child: Text('get loc'))
],
),
body: Stack(
children: <Widget>[
_googlemap(context),
suggestion(context),
/*_zoomout(),
_zoomin(),
_buildContainer(),*/
],
),
);
}
Widget _googlemap(BuildContext context) {
return Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: GoogleMap(
mapType: MapType.normal,
initialCameraPosition: CameraPosition(
target: pposition == null
? LatLng(
20.5937,
78.9629,
)
: LatLng(pposition.latitude, pposition.longitude),
zoom: 15.4,
),
circles: {myLOC},
markers: Set<Marker>.of(markers.values),
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
),
);
}
CollectionReference collectionReference =
Firestore.instance.collection('shopData');
Widget suggestion(BuildContext context) {
return SizedBox(
height: 80,
width: 200,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(30),
),
),
child: StreamBuilder(
stream: collectionReference.snapshots(),
builder:
(BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData)
return new SpinKitFadingCircle(
color: mydRed,
size: 50,
);
if (snapshot.error == true) {
Fluttertoast.showToast(
msg: snapshot.error.toString(),
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 2,
backgroundColor: bg,
textColor: mydRed,
fontSize: 16.0);
}
return new NotificationListener<OverscrollIndicatorNotification>(
onNotification: (overscroll) {
overscroll.disallowGlow();
},
child: ListView(
children: snapshot.data.documents.map(
(document) {
cardBuilder(
context: context, name: document['Name'].toString());
},
).toList(growable: true),
),
);
},
),
),
);
}
Widget cardBuilder({
BuildContext context,
String name,
}) {
return Align(child: Card(), alignment: Alignment.bottomLeft,);
}
//Markers below (mostly)
getClients() {
collectionReference.getDocuments().then((docs) {
if (docs.documents.isNotEmpty) {
for (int i = 0; i < docs.documents.length; ++i) {
initMarker(docs.documents[i].data, docs.documents[i].documentID);
}
}
});
}
Map<MarkerId, Marker> markers = <MarkerId, Marker>{};
initMarker(request, requestId) {
var markerIdVal = requestId;
final MarkerId markerId = MarkerId(markerIdVal);
//create marker
final Marker marker = Marker(
markerId: markerId,
position: LatLng(request['Lat'], request['Lon']),
infoWindow: InfoWindow(
title : request['Name'], snippet: request['Call']
),
);
setState(() {
markers[markerId] = marker;
print (markerId);
});
}
Circle myLOC = Circle(
circleId: CircleId('myLOC'),
center: pposition,
radius: 5,
fillColor: mydRed.withOpacity(0.4),
strokeColor: mydRed,
strokeWidth: 2,
);
}
class UserLocation {
final double latitude;
final double longitude;
UserLocation({this.latitude, this.longitude});
}
/*StreamBuilder(
stream: collectionReference.snapshots(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData)
return new SpinKitFadingCircle(
color: mydRed,
size: 50,
);
if (snapshot.error == true) {
Fluttertoast.showToast(
msg: snapshot.error.toString(),
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 2,
backgroundColor: bg,
textColor: mydRed,
fontSize: 16.0);
}
return new NotificationListener<OverscrollIndicatorNotification>(
onNotification: (overscroll) {
overscroll.disallowGlow();
},
child: ListView(
children: snapshot.data.documents.map(
(document) {
return new AppointmentCard(
name: document['Name'].toString(),
age: document['Age'].toString(),
mob: document['Mob'].toString(),
date: document['Date'].toString(),
serviceH: document['ServiceH'].toString(),
serviceS: document['ServiceS'].toString(),
//image: document['ImagePath'].toString(),
);
},
).toList(),
),
);
},
),
*/
控制台中的错误:-
I/flutter (25298): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (25298): The following NoSuchMethodError was thrown building GoogleMap(dirty, state: _GoogleMapState#0f8ef):
I/flutter (25298): The method 'toJson' was called on null.
I/flutter (25298): Receiver: null
I/flutter (25298): Tried calling: toJson()
I/flutter (25298): The relevant error-causing widget was:
I/flutter (25298): GoogleMap
I/flutter (25298): file:///D:/MYD/appBuilds/mydSalon/firebaseWorking/basicSignIn/lib/Navs/googleMapChoose.dart:71:14
I/flutter (25298): When the exception was thrown, this was the stack:
I/flutter (25298): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
I/flutter (25298): #1 Circle.toJson (package:google_maps_flutter_platform_interface/src/types/circle.dart:139:35)
I/flutter (25298): #2 serializeCircleSet.<anonymous closure> (package:google_maps_flutter_platform_interface/src/types/utils/circle.dart:21:60)
I/flutter (25298): #3 MappedIterator.moveNext (dart:_internal/iterable.dart:395:20)
I/flutter (25298): #4 new List.from (dart:core-patch/array_patch.dart:35:29)
I/flutter (25298): #5 Iterable.toList (dart:core/iterable.dart:400:12)
I/flutter (25298): #6 serializeCircleSet (package:google_maps_flutter_platform_interface/src/types/utils/circle.dart:21:70)
I/flutter (25298): #7 _GoogleMapState.build (package:google_maps_flutter/src/google_map.dart:225:23)
I/flutter (25298): #8 StatefulElement.build (package:flutter/src/widgets/framework.dart:4619:28)
I/flutter (25298): #9 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4502:15)
I/flutter (25298): #10 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:11)
I/flutter (25298): #11 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #12 StatefulElement.update (package:flutter/src/widgets/framework.dart:4707:5)
I/flutter (25298): #13 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #14 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5837:14)
I/flutter (25298): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #17 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #18 StatelessElement.update (package:flutter/src/widgets/framework.dart:4583:5)
I/flutter (25298): #19 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #20 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5522:32)
I/flutter (25298): #21 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5957:17)
I/flutter (25298): #22 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #23 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #24 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #25 StatelessElement.update (package:flutter/src/widgets/framework.dart:4583:5)
I/flutter (25298): #26 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #27 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #28 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #29 ProxyElement.update (package:flutter/src/widgets/framework.dart:4862:5)
I/flutter (25298): #30 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #31 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #32 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #33 ProxyElement.update (package:flutter/src/widgets/framework.dart:4862:5)
I/flutter (25298): #34 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #35 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5522:32)
I/flutter (25298): #36 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5957:17)
I/flutter (25298): #37 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #38 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #39 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:11)
I/flutter (25298): #40 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #41 StatefulElement.update (package:flutter/src/widgets/framework.dart:4707:5)
I/flutter (25298): #42 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #43 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #44 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #45 ProxyElement.update (package:flutter/src/widgets/framework.dart:4862:5)
I/flutter (25298): #46 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #47 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #48 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:11)
I/flutter (25298): #49 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #50 StatefulElement.update (package:flutter/src/widgets/framework.dart:4707:5)
I/flutter (25298): #51 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #52 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5837:14)
I/flutter (25298): #53 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #54 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #55 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #56 StatelessElement.update (package:flutter/src/widgets/framework.dart:4583:5)
I/flutter (25298): #57 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #58 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5837:14)
I/flutter (25298): #59 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #60 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #61 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:11)
I/flutter (25298): #62 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #63 StatefulElement.update (package:flutter/src/widgets/framework.dart:4707:5)
I/flutter (25298): #64 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #65 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #66 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:11)
I/flutter (25298): #67 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #68 StatefulElement.update (package:flutter/src/widgets/framework.dart:4707:5)
I/flutter (25298): #69 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #70 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #71 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #72 ProxyElement.update (package:flutter/src/widgets/framework.dart:4862:5)
I/flutter (25298): #73 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #74 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #75 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #76 ProxyElement.update (package:flutter/src/widgets/framework.dart:4862:5)
I/flutter (25298): #77 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #78 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #79 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:11)
I/flutter (25298): #80 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #81 StatefulElement.update (package:flutter/src/widgets/framework.dart:4707:5)
I/flutter (25298): #82 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #83 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #84 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:11)
I/flutter (25298): #85 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #86 StatefulElement.update (package:flutter/src/widgets/framework.dart:4707:5)
I/flutter (25298): #87 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #88 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5837:14)
I/flutter (25298): #89 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #90 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #91 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #92 StatelessElement.update (package:flutter/src/widgets/framework.dart:4583:5)
I/flutter (25298): #93 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #94 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5837:14)
I/flutter (25298): #95 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #96 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5837:14)
I/flutter (25298): #97 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #98 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #99 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:11)
I/flutter (25298): #100 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #101 StatefulElement.update (package:flutter/src/widgets/framework.dart:4707:5)
I/flutter (25298): #102 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #103 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5837:14)
I/flutter (25298): #104 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #105 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5837:14)
I/flutter (25298): #106 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #107 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #108 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:11)
I/flutter (25298): #109 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #110 StatefulElement.update (package:flutter/src/widgets/framework.dart:4707:5)
I/flutter (25298): #111 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #112 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #113 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #114 StatelessElement.update (package:flutter/src/widgets/framework.dart:4583:5)
I/flutter (25298): #115 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #116 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #117 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:11)
I/flutter (25298): #118 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #119 StatefulElement.update (package:flutter/src/widgets/framework.dart:4707:5)
I/flutter (25298): #120 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #121 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5837:14)
I/flutter (25298): #122 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #123 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #124 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #125 ProxyElement.update (package:flutter/src/widgets/framework.dart:4862:5)
I/flutter (25298): #126 _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:181:11)
I/flutter (25298): #127 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #128 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5837:14)
I/flutter (25298): #129 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #130 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #131 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:11)
I/flutter (25298): #132 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #133 StatefulElement.update (package:flutter/src/widgets/framework.dart:4707:5)
I/flutter (25298): #134 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #135 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #136 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #137 StatelessElement.update (package:flutter/src/widgets/framework.dart:4583:5)
I/flutter (25298): #138 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #139 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5837:14)
Reloaded 8 of 665 libraries in 2,569ms.
I/flutter (25298): #140 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #141 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #142 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #143 ProxyElement.update (package:flutter/src/widgets/framework.dart:4862:5)
I/flutter (25298): #144 Element.updateChild (package:flutter/src/widgets/framework.dart:3201:15)
I/flutter (25298): #145 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
I/flutter (25298): #146 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:11)
I/flutter (25298): #147 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
I/flutter (25298): #148 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2627:33)
I/flutter (25298): #149 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:883:20)
I/flutter (25298): #150 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:284:5)
I/flutter (25298): #151 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1113:15)
I/flutter (25298): #152 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1052:9)
I/flutter (25298): #153 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:861:7)
I/flutter (25298): (elided 4 frames from class _RawReceivePortImpl, class _Timer, and dart:async-patch)
I/flutter (25298): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (25298): Another exception was thrown: NoSuchMethodError: The getter 'key' was called on null.
I/flutter (25298): Another exception was thrown: NoSuchMethodError: The getter 'scrollOffsetCorrection' was called on null.
I/flutter (25298): Another exception was thrown: NoSuchMethodError: The method 'debugAssertIsValid' was called on null.
I/flutter (25298): Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null.
请帮助我消除此错误
我已经在pubspec.yaml、build.gradle和AndroidMenefest中正确安装了所有软件包
我有相同的错误
我是如何修复的?
-我将标记的图标从自定义图标更改为默认图标。
来自:
return Marker(
markerId: MarkerId(uniqeId),
position: _lastMapPosition,
infoWindow: InfoWindow(
title: name,
),
icon: await setCustomMapPin.getCustomMapPin(),
);
到此:
return Marker(
markerId: MarkerId(uniqeId),
position: _lastMapPosition,
infoWindow: InfoWindow(
title: name,
),
icon: BitmapDescriptor.defaultMarker,
);
如果你无论如何都想自定义,如果你不想崩溃,你应该在调用你的自定义图标之前使用这个
await setCustomMapPin.setCustomMapPin();
我认为myLOC
变量为null,因为它没有在initMarker
方法之外声明,所以在GoogleMap小部件中,您只是传递一个具有null 的Set
我也遇到了同样的问题,但就我而言,问题是由标记的infoWindow
引起的。
这也不能为null!
其默认值为:InfoWindow.noText
当您在加载地图时尝试异步设置一些标记时也会发生这种情况,重新绘制可能会导致此错误。这不是最佳的,但如果您选择在将标记添加到状态之前不渲染贴图,则可以防止此错误。