Fix restoration of search details page (#648)

pull/663/head
Michael Goderbauer 4 years ago committed by GitHub
parent b72fd311db
commit f96272db20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -99,12 +99,14 @@ class _SearchScreenState extends State<SearchScreen> with RestorationMixin {
final model = Provider.of<AppState>(context);
return UnmanagedRestorationScope(
bucket: bucket,
child: CupertinoTabView(
restorationScopeId: 'tabview',
builder: (context) {
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
statusBarBrightness:
MediaQuery.platformBrightnessOf(context)),
statusBarBrightness: MediaQuery.platformBrightnessOf(context),
),
child: SafeArea(
bottom: false,
child: Stack(
@ -113,7 +115,8 @@ class _SearchScreenState extends State<SearchScreen> with RestorationMixin {
_createSearchBox(),
],
),
));
),
);
},
),
);

@ -121,6 +121,29 @@ void main() {
expect(find.text('Tangelo'), findsOneWidget);
expect(find.text('Tan').hitTestable(), findsOneWidget); // search text
expect(find.text('Serving info'), findsNothing);
// Open a details page from search
await tester.tap(find.text('Tangelo'));
await tester.pumpAndSettle();
expect(find.text('Tangelo'), findsOneWidget);
expect(find.text('Serving info'), findsOneWidget);
// Restores details page
await tester.restartAndRestore();
expect(find.text('Tangelo'), findsOneWidget);
expect(find.text('Serving info'), findsOneWidget);
// Go back to search page, is also restored
tester.state<NavigatorState>(find.byType(Navigator).last).pop();
await tester.pumpAndSettle();
expect(find.text('Serving info'), findsNothing);
expect(find.text('Apples'), findsNothing);
expect(find.text('Tangelo'), findsOneWidget);
expect(find.text('Tan').hitTestable(), findsOneWidget); // search text
expect(find.text('Calorie Target'), findsNothing);
// Go to "Settings".

Loading…
Cancel
Save