startLocationStream method

Future<void> startLocationStream()

Implementation

Future<void> startLocationStream() async {
  await positionSub?.cancel();
  positionSub = locator
      .getPositionStream(
    locationSettings: const LocationSettings(accuracy: LocationAccuracy.high),
  )
      .listen((Position position) async {
    final updatedPosition = await locator.getCurrentPosition();
    final velocity = (position.speed + updatedPosition.speed) / 2;
    phoneSpeed.value = velocity * 18 / 5;
    widget._controller.position = position;
  });
}