feat(app): seed restaurants, geocode addresses, refresh sharing
This commit is contained in:
@@ -78,6 +78,28 @@ final locationStreamProvider = StreamProvider<Position>((ref) {
|
||||
);
|
||||
});
|
||||
|
||||
/// 초기 3초 내 위치를 가져오지 못하면 기본 좌표를 우선 반환하고,
|
||||
/// 이후 실제 위치 스트림이 들어오면 업데이트하는 Provider.
|
||||
final currentLocationWithFallbackProvider = StreamProvider<Position>((
|
||||
ref,
|
||||
) async* {
|
||||
final initial = await Future.any([
|
||||
ref
|
||||
.watch(currentLocationProvider.future)
|
||||
.then((pos) => pos ?? defaultPosition()),
|
||||
Future<Position>.delayed(
|
||||
const Duration(seconds: 3),
|
||||
() => defaultPosition(),
|
||||
),
|
||||
]).catchError((_) => defaultPosition());
|
||||
|
||||
yield initial;
|
||||
|
||||
yield* ref.watch(locationStreamProvider.stream).handleError((_) {
|
||||
// 스트림 오류는 무시하고 마지막 위치를 유지
|
||||
});
|
||||
});
|
||||
|
||||
/// 위치 관리 StateNotifier
|
||||
class LocationNotifier extends StateNotifier<AsyncValue<Position?>> {
|
||||
LocationNotifier() : super(const AsyncValue.loading());
|
||||
|
||||
Reference in New Issue
Block a user