mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
Fix restoration of search details page (#648)
This commit is contained in:
committed by
GitHub
parent
b72fd311db
commit
f96272db20
@@ -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(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@@ -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".
|
||||
|
||||
Reference in New Issue
Block a user