requestMyLocationLatLng method

  1. @override
Future<LatLng> requestMyLocationLatLng()
override

Implementation

@override
Future<LatLng> requestMyLocationLatLng() async {
  try {
    final Map<dynamic, dynamic> reply =
        await _channel.invokeMethod('locationComponent#getLastLocation');
    var latitude = 0.0;
    var longitude = 0.0;
    if (reply.containsKey('latitude') && reply['latitude'] != null) {
      latitude = double.parse(reply['latitude'].toString());
    }
    if (reply.containsKey('longitude') && reply['longitude'] != null) {
      longitude = double.parse(reply['longitude'].toString());
    }
    return LatLng(latitude, longitude);
  } on PlatformException catch (e) {
    return Future.error(e);
  }
}