diff --git a/kitchenowl/lib/pages/household_page.dart b/kitchenowl/lib/pages/household_page.dart index aa0adf84..90b9fa77 100644 --- a/kitchenowl/lib/pages/household_page.dart +++ b/kitchenowl/lib/pages/household_page.dart @@ -27,7 +27,8 @@ class HouseholdPage extends StatefulWidget { _HouseholdPageState createState() => _HouseholdPageState(); } -class _HouseholdPageState extends State { +class _HouseholdPageState extends State + with WidgetsBindingObserver { final GlobalKey scaffoldKey = GlobalKey(); late final HouseholdCubit householdCubit; @@ -44,10 +45,12 @@ class _HouseholdPageState extends State { recipeListCubit = RecipeListCubit(widget.household); plannerCubit = PlannerCubit(widget.household); expenseListCubit = ExpenseListCubit(widget.household); + WidgetsBinding.instance.addObserver(this); } @override void dispose() { + WidgetsBinding.instance.removeObserver(this); householdCubit.close(); shoppingListCubit.close(); recipeListCubit.close(); @@ -56,6 +59,14 @@ class _HouseholdPageState extends State { super.dispose(); } + @override + void didChangeAppLifecycleState(AppLifecycleState state) { + if (state == AppLifecycleState.resumed) { + householdCubit.refresh(); + shoppingListCubit.refresh(); + } + } + void _onItemTapped( BuildContext context, ViewsEnum tapped,