【发布时间】:2020-05-12 12:57:27
【问题描述】:
我在我的项目中使用了google_maps_flutter 库。当我热重载地图或从另一个视图返回地图时,它会崩溃并显示消息:
Exception has occurred.
PlatformException (PlatformException(error, java.lang.IllegalStateException: Trying to create an already created platform view, view id: 0
at io.flutter.plugin.platform.PlatformViewsController$1.createPlatformView(PlatformViewsController.java:85)
at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:96)
所以我试图处置地图及其控制器。我有一个代码 sn-p 来处理in this article 所以我添加了这个代码sn-p:
@override
void dispose() {
_disposeController();
super.dispose();
}
Future<void> _disposeController() async{
final GoogleMapController controller = await _controller.future;
//controller.dispose();
}
但取消注释最后一行给出了这个错误:
The method 'dispose' isn't defined for the class 'GoogleMapController'.
Try correcting the name to the name of an existing method, or defining a method named 'dispose'.
那么我该如何处置控制器呢?
【问题讨论】:
标签: flutter google-maps-flutter