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);
|
final model = Provider.of<AppState>(context);
|
||||||
|
|
||||||
return UnmanagedRestorationScope(
|
return UnmanagedRestorationScope(
|
||||||
|
bucket: bucket,
|
||||||
child: CupertinoTabView(
|
child: CupertinoTabView(
|
||||||
|
restorationScopeId: 'tabview',
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||||
value: SystemUiOverlayStyle(
|
value: SystemUiOverlayStyle(
|
||||||
statusBarBrightness:
|
statusBarBrightness: MediaQuery.platformBrightnessOf(context),
|
||||||
MediaQuery.platformBrightnessOf(context)),
|
),
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
bottom: false,
|
bottom: false,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
_buildSearchResults(model.searchVeggies(terms)),
|
_buildSearchResults(model.searchVeggies(terms)),
|
||||||
_createSearchBox(),
|
_createSearchBox(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
));
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -121,6 +121,29 @@ void main() {
|
|||||||
expect(find.text('Tangelo'), findsOneWidget);
|
expect(find.text('Tangelo'), findsOneWidget);
|
||||||
expect(find.text('Tan').hitTestable(), findsOneWidget); // search text
|
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);
|
expect(find.text('Calorie Target'), findsNothing);
|
||||||
|
|
||||||
// Go to "Settings".
|
// Go to "Settings".
|
||||||
|
|||||||
Reference in New Issue
Block a user