Fix Navigator.pop for named routes. (#11289)
* Prefix and Suffix support for TextFields * Adding Tests * Removing spurious newline. * Fixing a small problem with the test * Code review changes * Code Review Changes * Review Changes * Export the new StrokeJoin enum * Added example for line styles, and enabled line join styles. * Reverting inadvertent change to main.dart. * Updated due to code review of engine code * Removed example. * Added arguments to named routes, with test. * Fixing some formatting * Fixing Navigator.pop for named routes. * Fixing comment. * Simplifying test. * Fixing new -> const for Text object. * Tiny text change (also to kick a new Travis build) * Added a more realistic test case. * Reverting unintentional iml changes. * Fixing trailing newline * Removing some changes that snuck in.
This commit is contained in:
parent
aa096b50af
commit
e4860ef0eb
@ -307,7 +307,7 @@ class _MaterialAppState extends State<MaterialApp> {
|
|||||||
else
|
else
|
||||||
builder = widget.routes[name];
|
builder = widget.routes[name];
|
||||||
if (builder != null) {
|
if (builder != null) {
|
||||||
return new MaterialPageRoute<Null>(
|
return new MaterialPageRoute<dynamic>(
|
||||||
builder: builder,
|
builder: builder,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
);
|
);
|
||||||
|
@ -106,7 +106,7 @@ void main() {
|
|||||||
return new Builder(
|
return new Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
++buildCounter;
|
++buildCounter;
|
||||||
return new Container();
|
return const Text('Y');
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -129,6 +129,7 @@ void main() {
|
|||||||
expect(buildCounter, 1);
|
expect(buildCounter, 1);
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
expect(buildCounter, 2);
|
expect(buildCounter, 2);
|
||||||
|
expect(find.text('Y'), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Cannot pop the initial route', (WidgetTester tester) async {
|
testWidgets('Cannot pop the initial route', (WidgetTester tester) async {
|
||||||
@ -171,7 +172,47 @@ void main() {
|
|||||||
expect(find.text('route "/b"'), findsNothing);
|
expect(find.text('route "/b"'), findsNothing);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Two-step initial route', (WidgetTester tester) async {
|
testWidgets('Return value from pop is correct', (WidgetTester tester) async {
|
||||||
|
Future<String> result;
|
||||||
|
await tester.pumpWidget(
|
||||||
|
new MaterialApp(
|
||||||
|
home: new Builder(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return new Material(
|
||||||
|
child: new RaisedButton(
|
||||||
|
child: const Text('X'),
|
||||||
|
onPressed: () async {
|
||||||
|
result = Navigator.of(context).pushNamed('/a');
|
||||||
|
}
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
routes: <String, WidgetBuilder>{
|
||||||
|
'/a': (BuildContext context) {
|
||||||
|
return new Material(
|
||||||
|
child: new RaisedButton(
|
||||||
|
child: const Text('Y'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop('all done');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
);
|
||||||
|
await tester.tap(find.text('X'));
|
||||||
|
await tester.pump();
|
||||||
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
expect(find.text('Y'), findsOneWidget);
|
||||||
|
await tester.tap(find.text('Y'));
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
expect(await result, equals('all done'));
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Two-step initial route', (WidgetTester tester) async {
|
||||||
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
|
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
|
||||||
'/': (BuildContext context) => const Text('route "/"'),
|
'/': (BuildContext context) => const Text('route "/"'),
|
||||||
'/a': (BuildContext context) => const Text('route "/a"'),
|
'/a': (BuildContext context) => const Text('route "/a"'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user