From cc7da5a045051b2ab328fd70b71cb78858caa826 Mon Sep 17 00:00:00 2001 From: shilangyu Date: Sun, 20 Sep 2020 23:27:04 +0200 Subject: [PATCH] preserve state on tab change --- lib/main.dart | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index f6ee448..c2fe3a1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -76,11 +76,6 @@ class MyHomePage extends HookWidget { UserProfileTab(), ]; - // TODO: does this even work? the state seems to be popped - // for example: go to user tab, wait for it to load, - // go to a different tab, go back, the data is loading again - final PageStorageBucket pageStorageBucket = PageStorageBucket(); - @override Widget build(BuildContext context) { final theme = Theme.of(context); @@ -109,9 +104,10 @@ class MyHomePage extends HookWidget { } return Scaffold( - body: PageStorage( - bucket: pageStorageBucket, - child: pages[currentTab.value], + extendBody: true, + body: IndexedStack( + index: currentTab.value, + children: pages, ), floatingActionButton: FloatingActionButton( child: Icon(Icons.add),