Skip to content
Merged
Show file tree
Hide file tree
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
27 changes: 15 additions & 12 deletions experimental/veggieseasons/lib/screens/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,24 @@ 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)),
child: SafeArea(
bottom: false,
child: Stack(
children: [
_buildSearchResults(model.searchVeggies(terms)),
_createSearchBox(),
],
),
));
value: SystemUiOverlayStyle(
statusBarBrightness: MediaQuery.platformBrightnessOf(context),
),
child: SafeArea(
bottom: false,
child: Stack(
children: [
_buildSearchResults(model.searchVeggies(terms)),
_createSearchBox(),
],
),
),
);
},
),
);
Expand Down
23 changes: 23 additions & 0 deletions experimental/veggieseasons/test/restoration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down