Fixed In Progress ISR not reflecting on IT Staff Pulse Dashboard Status Pill

Made the Location Tracking more persistent
This commit is contained in:
2026-03-11 07:43:14 +08:00
parent 24ecca9f06
commit 21e6d68910
6 changed files with 78 additions and 7 deletions
+20
View File
@@ -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,