Skip to content

Commit 417a662

Browse files
committed
Fix restoration of search details page
1 parent 4d5b3a8 commit 417a662

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

experimental/veggieseasons/lib/screens/search.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,24 @@ class _SearchScreenState extends State<SearchScreen> with RestorationMixin {
9999
final model = Provider.of<AppState>(context);
100100

101101
return UnmanagedRestorationScope(
102+
bucket: bucket,
102103
child: CupertinoTabView(
104+
restorationScopeId: 'tabview',
103105
builder: (context) {
104106
return AnnotatedRegion<SystemUiOverlayStyle>(
105-
value: SystemUiOverlayStyle(
106-
statusBarBrightness:
107-
MediaQuery.platformBrightnessOf(context)),
108-
child: SafeArea(
109-
bottom: false,
110-
child: Stack(
111-
children: [
112-
_buildSearchResults(model.searchVeggies(terms)),
113-
_createSearchBox(),
114-
],
115-
),
116-
));
107+
value: SystemUiOverlayStyle(
108+
statusBarBrightness: MediaQuery.platformBrightnessOf(context),
109+
),
110+
child: SafeArea(
111+
bottom: false,
112+
child: Stack(
113+
children: [
114+
_buildSearchResults(model.searchVeggies(terms)),
115+
_createSearchBox(),
116+
],
117+
),
118+
),
119+
);
117120
},
118121
),
119122
);

experimental/veggieseasons/test/restoration_test.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,29 @@ void main() {
121121
expect(find.text('Tangelo'), findsOneWidget);
122122
expect(find.text('Tan').hitTestable(), findsOneWidget); // search text
123123

124+
expect(find.text('Serving info'), findsNothing);
125+
126+
// Open a details page from search
127+
await tester.tap(find.text('Tangelo'));
128+
await tester.pumpAndSettle();
129+
130+
expect(find.text('Tangelo'), findsOneWidget);
131+
expect(find.text('Serving info'), findsOneWidget);
132+
133+
// Restores details page
134+
await tester.restartAndRestore();
135+
expect(find.text('Tangelo'), findsOneWidget);
136+
expect(find.text('Serving info'), findsOneWidget);
137+
138+
// Go back to search page, is also restored
139+
tester.state<NavigatorState>(find.byType(Navigator).last).pop();
140+
await tester.pumpAndSettle();
141+
142+
expect(find.text('Serving info'), findsNothing);
143+
expect(find.text('Apples'), findsNothing);
144+
expect(find.text('Tangelo'), findsOneWidget);
145+
expect(find.text('Tan').hitTestable(), findsOneWidget); // search text
146+
124147
expect(find.text('Calorie Target'), findsNothing);
125148

126149
// Go to "Settings".

0 commit comments

Comments
 (0)