getLocation method

  1. @override
Future<LocationData> getLocation()
override

Gets the current location of the user.

Throws an error if the app has no permission to access location. Returns a LocationData object.

Implementation

@override
Future<LocationData> getLocation() async {
  final resultMap =
      await _methodChannel!.invokeMapMethod<String, dynamic>('getLocation');
  if (resultMap == null) {
    throw PlatformException(
      code: 'NULL_RESULT',
      message: 'The results from getLocation is null',
    );
  }
  return LocationData.fromMap(resultMap);
}