0

首次构建地图时

GoogleMap(
  initialCameraPosition: _startPosition,
  myLocationEnabled: true,
);

系统请求许可

1

我怎样才能抓住用户做出选择的那一刻?

4

1 回答 1

0

您可以使用位置插件hasPermission使用位置类的方法。从这里你可以捕捉到这一刻。请看下面:-

final _hasLocationPermission = await location.hasPermission();
      if (_hasLocationPermission == PermissionStatus.granted) {
        //Code here
      } else if (_hasLocationPermission == PermissionStatus.denied) {
        final _permissionGranted = await location.requestPermission();
        if (_permissionGranted == PermissionStatus.granted) {
         //Code here
        } else if (_permissionGranted == PermissionStatus.denied) {
          //Code here
        }
      }
于 2020-12-27T14:48:33.900 回答