Fixed In Progress ISR not reflecting on IT Staff Pulse Dashboard Status Pill
Made the Location Tracking more persistent
This commit is contained in:
@@ -4,6 +4,9 @@ import 'package:flutter_quill/flutter_quill.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'routing/app_router.dart';
|
||||
import 'models/profile.dart';
|
||||
import 'providers/profile_provider.dart';
|
||||
import 'services/background_location_service.dart';
|
||||
import 'theme/app_theme.dart';
|
||||
|
||||
class TasqApp extends ConsumerWidget {
|
||||
@@ -13,6 +16,23 @@ class TasqApp extends ConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final router = ref.watch(appRouterProvider);
|
||||
|
||||
// Ensure background service is running if the profile indicates tracking.
|
||||
// This handles the case where the app restarts while tracking was already
|
||||
// enabled (service should persist, but this guarantees it). It also stops
|
||||
// the service when tracking is disabled externally.
|
||||
ref.listen<AsyncValue<Profile?>>(currentProfileProvider, (
|
||||
previous,
|
||||
next,
|
||||
) async {
|
||||
final profile = next.valueOrNull;
|
||||
final allow = profile?.allowTracking ?? false;
|
||||
if (allow) {
|
||||
await startBackgroundLocationUpdates();
|
||||
} else {
|
||||
await stopBackgroundLocationUpdates();
|
||||
}
|
||||
});
|
||||
|
||||
return MaterialApp.router(
|
||||
title: 'TasQ',
|
||||
routerConfig: router,
|
||||
|
||||
Reference in New Issue
Block a user