position property

  1. @override
Future<Position?> get position
override

Implementation

@override
Future<Position?> get position async {
  final cachedPositionDate = this.cachedPositionDate;
  final cachedPosition = this.cachedPosition;

  if (cachedPosition != null && cachedPositionDate != null) {
    final timeDiff = DateTime.now().difference(cachedPositionDate);
    if (timeDiff < positionCacheDuration) return cachedPosition;
  }

  this.cachedPosition = await Geolocator.getCurrentPosition();
  return this.cachedPosition;
}