Geofence test screen

This commit is contained in:
2026-02-19 06:49:21 +08:00
parent f9f3509188
commit 5488238051
9 changed files with 852 additions and 4 deletions
+28
View File
@@ -0,0 +1,28 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:geolocator/geolocator.dart';
/// Provides the device current position on demand. Tests may override this
/// provider to inject a fake Position.
final currentPositionProvider = FutureProvider.autoDispose<Position>((
ref,
) async {
// Mirror the runtime usage in the app: ask geolocator for the current
// position with high accuracy. Caller (UI) should handle permission
// flows / errors.
final position = await Geolocator.getCurrentPosition(
locationSettings: const LocationSettings(accuracy: LocationAccuracy.high),
);
return position;
});
/// Stream of device positions for live tracking. Tests can override this
/// provider to inject a fake stream.
final currentPositionStreamProvider = StreamProvider.autoDispose<Position>((
ref,
) {
const settings = LocationSettings(
accuracy: LocationAccuracy.high,
distanceFilter: 5, // small filter for responsive UI in tests/dev
);
return Geolocator.getPositionStream(locationSettings: settings);
});
+1 -1
View File
@@ -13,7 +13,7 @@ final currentUserIdProvider = Provider<String?>((ref) {
return authState.when(
data: (state) => state.session?.user.id,
loading: () => ref.watch(sessionProvider)?.user.id,
error: (_, __) => ref.watch(sessionProvider)?.user.id,
error: (error, _) => ref.watch(sessionProvider)?.user.id,
);
});