feat: wire up app shell, log mood screen, and fix Android build
- Bootstrap ProviderScope in main.dart and move App to app.dart with light/dark theming - Add initial LogMoodScreen with mood entry flow and shared activity/mood widgets - Add kIsWeb guard in app_database.dart for drift web support - Enable Android core library desugaring required by flutter_local_notifications 21.x - Guard all async notifier state assignments with ref.mounted checks to prevent use-after-dispose errors when providers are auto-disposed mid-operation
This commit is contained in:
@@ -57,7 +57,7 @@ class MoodEntryNotifier extends Notifier<AsyncValue<void>> {
|
||||
DateTime? timestamp,
|
||||
}) async {
|
||||
state = const AsyncLoading();
|
||||
state = await AsyncValue.guard(() async {
|
||||
final next = await AsyncValue.guard(() async {
|
||||
final dao = ref.read(moodDaoProvider);
|
||||
await dao.insertEntryWithActivities(
|
||||
entry: MoodEntriesCompanion.insert(
|
||||
@@ -69,13 +69,17 @@ class MoodEntryNotifier extends Notifier<AsyncValue<void>> {
|
||||
tagIds: tagIds,
|
||||
);
|
||||
});
|
||||
if (!ref.mounted) return;
|
||||
state = next;
|
||||
}
|
||||
|
||||
Future<void> deleteEntry(int id) async {
|
||||
state = const AsyncLoading();
|
||||
state = await AsyncValue.guard(
|
||||
final next = await AsyncValue.guard(
|
||||
() => ref.read(moodDaoProvider).deleteEntry(id),
|
||||
);
|
||||
if (!ref.mounted) return;
|
||||
state = next;
|
||||
}
|
||||
|
||||
Future<void> updateEntry({
|
||||
@@ -85,7 +89,7 @@ class MoodEntryNotifier extends Notifier<AsyncValue<void>> {
|
||||
DateTime? timestamp,
|
||||
}) async {
|
||||
state = const AsyncLoading();
|
||||
state = await AsyncValue.guard(
|
||||
final next = await AsyncValue.guard(
|
||||
() => ref.read(moodDaoProvider).updateEntry(
|
||||
MoodEntriesCompanion(
|
||||
id: Value(id),
|
||||
@@ -95,6 +99,8 @@ class MoodEntryNotifier extends Notifier<AsyncValue<void>> {
|
||||
),
|
||||
),
|
||||
);
|
||||
if (!ref.mounted) return;
|
||||
state = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user