requestLocationPermission method

Future<bool> requestLocationPermission (
  1. {String provider: LocationProvider.GPS}

whenever you require location data, first make sure you have called this method, to check whether location permission is available or not. if permission is already granted, it'll simply return true is runtime permission is denied by user, it'll return false. decision to perform further operation needs to be taken by watching this methods result well it's async ;)


Future<bool> requestLocationPermission(
    {String provider: LocationProvider.GPS}) async {
  try {
    return await _methodChannel.invokeMethod(
        'requestLocationPermission', <String, int>{
      'id': provider == LocationProvider.GPS ? 0 : 1
    }).then((dynamic result) => result == 1 ? true : false);
  } on PlatformException {
    return false;