小编Mal*_*gne的帖子

Flutter google map如何在GoogleMap的小部件onCreated函数之外实例化GoogleMapController以进行测试?

我正在使用插件 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)

我尝试了多种方法,但没有任何效果,有人可以帮助我吗?

testing google-maps flutter

5
推荐指数
1
解决办法
6273
查看次数

标签 统计

flutter ×1

google-maps ×1

testing ×1