Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Refresh shopping list on resume #540

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion kitchenowl/lib/pages/household_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class HouseholdPage extends StatefulWidget {
_HouseholdPageState createState() => _HouseholdPageState();
}

class _HouseholdPageState extends State<HouseholdPage> {
class _HouseholdPageState extends State<HouseholdPage>
with WidgetsBindingObserver {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();

late final HouseholdCubit householdCubit;
Expand All @@ -44,10 +45,12 @@ class _HouseholdPageState extends State<HouseholdPage> {
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();
Expand All @@ -56,6 +59,14 @@ class _HouseholdPageState extends State<HouseholdPage> {
super.dispose();
}

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) {
householdCubit.refresh();
shoppingListCubit.refresh();
}
}

void _onItemTapped(
BuildContext context,
ViewsEnum tapped,
Expand Down
Loading