Skip to content

Commit

Permalink
Fix Errors occurring after View is already disposed
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkoerber committed Nov 30, 2024
1 parent eb34550 commit 361fd04
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/calendarComponent/views/event_creation_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class EventCreationView extends ConsumerWidget {
.read(calendarAdditionViewModel(calendarEvent))
.saveEvent()
.then((value) {
ref.invalidate(calendarAdditionViewModel);
if (context.mounted) {
ref.invalidate(calendarAdditionViewModel);
context.canPop() ? context.pop() : context.go(calendar);
}
})
Expand Down
29 changes: 16 additions & 13 deletions lib/placesComponent/views/homeWidget/cafeteria_widget_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,22 @@ class _CafeteriaWidgetViewState extends ConsumerState<CafeteriaWidgetView> {
Icons.filter_list,
color: context.primaryColor,
),
onTap: () => showModalBottomSheet(
builder: (context) => PreferenceSelectionView<Cafeteria>(
data: ref
.read(cafeteriasViewModel)
.getCafeteriaEntries(context),
entry: context.tr("cafeteria"),
),
context: context,
useRootNavigator: true,
isScrollControlled: true,
useSafeArea: true,
showDragHandle: true,
),
onTap: () => context.mounted
? showModalBottomSheet(
builder: (context) =>
PreferenceSelectionView<Cafeteria>(
data: ref
.read(cafeteriasViewModel)
.getCafeteriaEntries(context),
entry: context.tr("cafeteria"),
),
context: context,
useRootNavigator: true,
isScrollControlled: true,
useSafeArea: true,
showDragHandle: true,
)
: null,
),
],
),
Expand Down
4 changes: 3 additions & 1 deletion lib/settingsComponent/views/settings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ class SettingsView extends ConsumerWidget {

Widget _resetPreferencesButton(BuildContext context, WidgetRef ref) {
return ListTile(
onTap: () => ref.read(onboardingViewModel).resetPreferences(ref),
onTap: () => context.mounted
? ref.read(onboardingViewModel).resetPreferences(ref)
: null,
dense: true,
title: Text(
context.tr("resetPreferences"),
Expand Down

0 comments on commit 361fd04

Please sign in to comment.