首次构建地图时
GoogleMap(
initialCameraPosition: _startPosition,
myLocationEnabled: true,
);
系统请求许可
我怎样才能抓住用户做出选择的那一刻?
首次构建地图时
GoogleMap(
initialCameraPosition: _startPosition,
myLocationEnabled: true,
);
系统请求许可
我怎样才能抓住用户做出选择的那一刻?
您可以使用位置插件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
}
}