Add Android background geolocation with notification error handling
Add flutter_background_geolocation for background location tracking on Android. Service automatically sends coordinates to server when app is in background. Error messages are shown as system notifications using flutter_local_notifications.
This commit is contained in:
+11
-2
@@ -6,6 +6,7 @@ import 'providers/map_provider.dart';
|
||||
import 'providers/share_provider.dart';
|
||||
import 'screens/login_screen.dart';
|
||||
import 'screens/map_screen.dart';
|
||||
import 'services/background_geo_service.dart';
|
||||
import 'services/settings_service.dart';
|
||||
|
||||
void main() async {
|
||||
@@ -13,13 +14,20 @@ void main() async {
|
||||
final settings = SettingsService();
|
||||
await settings.initialize();
|
||||
ApiConfig.setBaseUrl(settings.baseUrl);
|
||||
runApp(MyApp(settingsService: settings));
|
||||
final bgGeo = BackgroundGeoService();
|
||||
await bgGeo.init();
|
||||
runApp(MyApp(settingsService: settings, bgGeo: bgGeo));
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
final SettingsService settingsService;
|
||||
final BackgroundGeoService bgGeo;
|
||||
|
||||
const MyApp({super.key, required this.settingsService});
|
||||
const MyApp({
|
||||
super.key,
|
||||
required this.settingsService,
|
||||
required this.bgGeo,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -29,6 +37,7 @@ class MyApp extends StatelessWidget {
|
||||
ChangeNotifierProvider(create: (_) => AuthProvider()),
|
||||
ChangeNotifierProvider(create: (_) => MapProvider()),
|
||||
ChangeNotifierProvider(create: (_) => ShareProvider()),
|
||||
Provider.value(value: bgGeo),
|
||||
],
|
||||
child: MaterialApp(
|
||||
title: 'Family Safety',
|
||||
|
||||
Reference in New Issue
Block a user