49 lines
1.3 KiB
Dart
49 lines
1.3 KiB
Dart
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:geolocator/geolocator.dart';
|
|
|
|
final policeAlertServiceProvider = Provider<PoliceAlertService>((ref) {
|
|
return MockPoliceAlertService();
|
|
});
|
|
|
|
class PoliceAlert {
|
|
final String title;
|
|
final double distanceMiles;
|
|
final Position location;
|
|
|
|
PoliceAlert({
|
|
required this.title,
|
|
required this.distanceMiles,
|
|
required this.location,
|
|
});
|
|
}
|
|
|
|
abstract class PoliceAlertService {
|
|
Future<List<PoliceAlert>> getNearbyAlerts(Position currentPosition, double heading);
|
|
}
|
|
|
|
class MockPoliceAlertService implements PoliceAlertService {
|
|
@override
|
|
Future<List<PoliceAlert>> getNearbyAlerts(Position currentPosition, double heading) async {
|
|
// Return a mock alert for demonstration/testing
|
|
// A real implementation would query a backend or a 3rd party API (if legally available)
|
|
return [
|
|
PoliceAlert(
|
|
title: 'SPEED TRAP',
|
|
distanceMiles: 0.7,
|
|
location: Position(
|
|
latitude: currentPosition.latitude + 0.01,
|
|
longitude: currentPosition.longitude + 0.01,
|
|
timestamp: DateTime.now(),
|
|
accuracy: 5.0,
|
|
altitude: 0.0,
|
|
heading: 0.0,
|
|
speed: 0.0,
|
|
speedAccuracy: 0.0,
|
|
altitudeAccuracy: 0.0,
|
|
headingAccuracy: 0.0,
|
|
),
|
|
)
|
|
];
|
|
}
|
|
}
|