SHARE
TWEET

Untitled

a guest Sep 15th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PermissionStatus _permissionStatus;
  2.  
  3.   void _askPermission() {
  4.     PermissionHandler().requestPermissions(
  5.         [PermissionGroup.locationWhenInUse]).then(_onStatusRequested);
  6.   }
  7.  
  8.   void _onStatusRequested(Map<PermissionGroup, PermissionStatus> statuses) {
  9.     final status = statuses[PermissionGroup.locationWhenInUse];
  10.     if (status != PermissionStatus.granted) {
  11.       PermissionHandler().openAppSettings();
  12.     } else {
  13.       _updateStatus(status);
  14.       Navigator.of(context).pushReplacement(
  15.           new MaterialPageRoute(builder: (context) => new MyAppState()));
  16.     }
  17.   }
  18.  
  19.   void _updateStatus(PermissionStatus status) {
  20.     if (status != _permissionStatus) {
  21.       setState(() {
  22.         _permissionStatus = status;
  23.       });
  24.     }
  25.   }
  26.  
  27.   void initState() {
  28.     super.initState();
  29.     PermissionHandler()
  30.         .checkPermissionStatus(PermissionGroup.locationWhenInUse)
  31.         .then(_updateStatus);
  32.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top