watchLocation method

  1. @override
Future<String?> watchLocation()
override

The function watchLocation checks if a location stream is already added and returns the location if available, otherwise throws an error. @returns The method watchLocation() returns a Future<String?>.

Implementation

@override
Future<String?> watchLocation() async {
  if (_locationStream == null) {
    final returnVal =
        await methodChannel.invokeMethod<String>('watchLocation');
    return returnVal;
  } else {
    throw ("Location watch already added");
  }
}