initLocation method

Future<void> initLocation()

Implementation

Future<void> initLocation() async {
  bool serviceEnabled;
  //PermissionStatus permissionGranted;
  serviceEnabled = await location.serviceEnabled();
  if (!serviceEnabled) {
    serviceEnabled = await location.requestService();
    if (!serviceEnabled) {
      return;
    }
  }

  locationSC.stream.listen((event) {
    duration = ((event.time ?? 0) - (lastFix?.time ?? 0)).toInt();
    distance = geodesy
        .distanceBetweenTwoGeoPoints(
          geodes.LatLng(event.latitude ?? 0, event.longitude ?? 0),
          geodes.LatLng(lastFix?.latitude ?? 0, lastFix?.longitude ?? 0),
        )
        .toDouble();
    lastFix = event;

    //  rfn.Controller.move(
    //     LatLng(lastFix?.latitude ?? 0, lastFix?.longitude ?? 0),
    //     16,
    //   );
  });
}