Mal*_*gne 5 testing google-maps flutter
我正在使用插件 google_maps_flutter 1.2.0,我想实例化一个 GoogleMapController 来测试一些块的事件,其中控制器的值不能为空。不幸的是,我不知道该怎么做,因为据我所知,GoogleMapController 无法在 GoogleMap() Widget 的“OnCreated”函数之外实例化。
GoogleMap(onMapCreated: (GoogleMapController controller) {
// Can only be instanciate here
},
);
Run Code Online (Sandbox Code Playgroud)
不可能做这样的事情:
GoogleMapController controller = new GoogleMapsController();
Run Code Online (Sandbox Code Playgroud)
我只能这样做,并且控制器为 null :
GoogleMapController controller;
Run Code Online (Sandbox Code Playgroud)
我尝试了多种方法,但没有任何效果,有人可以帮助我吗?
首先,GoogleMapController _googleMapController在你的_WidgetState.
然后
GoogleMap(onMapCreated: (GoogleMapController controller) {
_googleMapController = controller;
}
);
Run Code Online (Sandbox Code Playgroud)
创建 Google 地图后,您可以在小部件中的任何位置使用 _googleMapController。
| 归档时间: |
|
| 查看次数: |
6273 次 |
| 最近记录: |