断言失败:第24行pos 15:'initialCameraPosition!= null':不正确

时间:2019-01-31 07:57:10

标签: flutter maps

我已在pubspec.yaml的库下面插入了

  google_maps_flutter:
    git:
      url: git://github.com/flutter/plugins
      path: packages/google_maps_flutter

但是我每次都会出错

Another exception was thrown: 'file:///C:/src/flutter/.pub-cache/git/plugins-aedcc6f81843ae2da3a6ac0c8e8c4b530d1ac035/packages/google_maps_flutter/lib/src/google_map.dart': Failed assertion: line 24 pos 15: 'initialCameraPosition != null': is not true.

谢谢。

1 个答案:

答案 0 :(得分:2)

只需在GoogleMap()中使用initialCameraPosition 例如:

GoogleMap(
              onMapCreated: _onMapCreated,
              initialCameraPosition: CameraPosition(target: LatLng(51.5160895, -0.1294527),),
            )