我在我的项目中使用了 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)
所以我试图处理地图及其控制器。我在这篇文章中有一个要处理的代码片段 所以我添加了这个代码片段:
@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'.
那我该如何处置控制器?