在频道映射上未找到用于方法摄像机动画的实现
无法工作
依赖版本= google_maps_flutter: ^2.1.6
实施代码
Future<void> _goToTheLake() async {
LatLng lat = LatLng(ctrl.getLat().value, ctrl.getLang().value);
print(lat);
final GoogleMapController controller = await _controller.future;
controller.animateCamera(
CameraUpdate.newCameraPosition(
CameraPosition(target: lat, zoom: 15.0)));
setState(() {});
}
E/flutter (15144): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method camera#animate on channel plugins.flutter.io/google_maps_0)
E/flutter (15144): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7)
E/flutter (15144): <asynchronous suspension>
“扑波图近年”按钮 解决方案请发表评论。
The Flutter map recenter button not working
dependency version = google_maps_flutter: ^2.1.6
Implement code
Future<void> _goToTheLake() async {
LatLng lat = LatLng(ctrl.getLat().value, ctrl.getLang().value);
print(lat);
final GoogleMapController controller = await _controller.future;
controller.animateCamera(
CameraUpdate.newCameraPosition(
CameraPosition(target: lat, zoom: 15.0)));
setState(() {});
}
E/flutter (15144): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method camera#animate on channel plugins.flutter.io/google_maps_0)
E/flutter (15144): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7)
E/flutter (15144): <asynchronous suspension>
if anyone has a solution please drop a comment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这对我来说很好
here's works fine for me
希望这会有所帮助
Hope this helps
像这样留下您的依赖。如果仍然不起作用,请保存它
通过以下步骤:
在终端:
Leave your dependency like this. Then save it if it's still not working
go through these steps:
In terminal:
它不完全在文档中,而是在示例
这解决了我们的问题。
It's not exactly in the docs but in the example
This fixed the problem for us.
正如许多其他线程所说的那样,这个问题的答案是
mapController = ploteer();
,但对于许多人,在
void dispose()
中都称其为不会解决您的问题。如果您的
googlemap(..)
内部的小部件(如果)在下面的示例中,如果(loadSearch)? ShowearchViewWidget():Showmapswidget();
您需要调用
mapController = ploteer();
其中loadsearch = true
。您可能已经了解了现在的工作原理。基本上,
完成器
完成后,当您调用等待_mapcontrollerComment.future;
时,将始终尽快返回。不会等待googlemap(... onmapCreated())
完成。当您将loadSearch
设置为false时,需要等待googlemap(... onmapCreated())
在调用动画之前。再次初始化mapcontroller时,当您将loadSearch
设置为true时,将使等待_mapcontrollerCompleter.future;
等待googlemap(... onmapCreated(... onmapCreated())正确完成。
The answer to this issue, as many other threads says is
mapController = Completer();
but for many of you calling it in
void dispose()
wont solve your issue.if you have your
GoogleMap(..)
widget inside anif
like in the below exampleif(loadSearch)? showSearchViewWidget() : showMapsWidget();
you need to call
mapController = Completer();
where you setloadSearch = true
.you may have understood how it works by now. its basically that the
Completer
once completed, will always return asap when you callawait _mapControllerCompleter.future;
. wont wait forGoogleMap(...onMapCreated())
to finish. when you setloadSearch
to false, you need to wait forGoogleMap(...onMapCreated())
before calling animate. initializing mapController again when you setloadSearch
to true, will makeawait _mapControllerCompleter.future;
wait forGoogleMap(...onMapCreated())
to properly finish.