fetchAndSaveLocationProvider top-level property

AutoDisposeFutureProvider<LocationFlowResult> fetchAndSaveLocationProvider
final

Fetches current location and persists when successful.

Implementation

final fetchAndSaveLocationProvider =
    FutureProvider.autoDispose<LocationFlowResult>((ref) async {
  final kit = ref.watch(locationKitProvider);
  final storage = ref.watch(locationStorageProvider);
  final result = await kit.fetchCurrentLocation();
  if (result is LocationFlowSuccess) {
    await storage.save(result.fix);
  }
  return result;
});