[英]Flutter: How can I update my InkResponse or InkWell string value every time my camera moves?
这是我的 InkResponse:
new InkResponse(
child: new Container(
color: Colors.green,
child: new Center(
child: new Text(
(_lastMapPosition.toString()),
我最后的地图位置参数:
LatLng _lastMapPosition = _center;
void _onCameraMove(CameraPosition cameraPosition) {
_currentZoom = cameraPosition.zoom;
_lastMapPosition = cameraPosition.target;
print(_lastMapPosition);
}
和我的谷歌地图:
SizedBox(
width:
MediaQuery.of(context).size.width, // or use fixed size like 200
height: MediaQuery.of(context).size.height,
child: Consumer<ProviderMaps>(builder: (context, Provmap, widget) {
return GoogleMap(
myLocationEnabled: true,
compassEnabled: true,
mapToolbarEnabled: true,
zoomControlsEnabled: true,
zoomGesturesEnabled: true,
onCameraMove: _onCameraMove,
当我通过滚动(相机移动)改变我的位置时,我能够快速打印 print(_lastMapPosition) 。 我希望将 _lastMapPosition 字符串发送到我的 InkResponse 并在每次滚动时更新。 我怎样才能做到这一点?
void _onCameraMove(CameraPosition cameraPosition) {
_currentZoom = cameraPosition.zoom;
_lastMapPosition = cameraPosition.target;
setState(() {
_lastMapPosition;
});
print(_lastMapPosition);
}
new InkResponse(
child: new Container(
color: Colors.grey,
child: new Center(
child: new Text(
(_lastMapPosition).toString(),
)))),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.