- Implement EmergencyService for handling emergency contacts per trip. - Create GuestFlagService to manage guest mode flags for trips. - Introduce NotificationService with local notification capabilities. - Add OfflineFlagService for managing offline caching flags. - Develop PackingService for shared packing lists per trip. - Implement ReminderService for managing reminders/to-dos per trip. - Create SosService for dispatching SOS events to a backend. - Add StorageService with album image upload functionality. - Implement TransportService for managing transport segments per trip. - Create TripChecklistService for storing and retrieving trip checklists. - Add TripDocumentService for persisting trip documents metadata. test: Add unit tests for new services - Implement tests for AlbumService, BudgetService, EmergencyService, GuestFlagService, PackingService, ReminderService, SosService, TransportService, TripChecklistService, and TripDocumentService. - Ensure tests cover adding, loading, deleting, and handling corrupted payloads for each service.
19 lines
665 B
Dart
19 lines
665 B
Dart
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
/// Stores a per-trip offline toggle to trigger background caching later.
|
|
class OfflineFlagService {
|
|
/// Returns whether offline caching is enabled for [tripId].
|
|
Future<bool> isOfflineEnabled(String tripId) async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
return prefs.getBool(_key(tripId)) ?? false;
|
|
}
|
|
|
|
/// Persists the offline toggle.
|
|
Future<void> setOfflineEnabled(String tripId, bool enabled) async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
await prefs.setBool(_key(tripId), enabled);
|
|
}
|
|
|
|
String _key(String tripId) => 'offline_trip_$tripId';
|
|
}
|