Commit e4860ef0 authored by gspencergoog's avatar gspencergoog Committed by Ian Hickson

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.
parent aa096b50
......@@ -307,7 +307,7 @@ class _MaterialAppState extends State<MaterialApp> {
else
builder = widget.routes[name];
if (builder != null) {
return new MaterialPageRoute<Null>(
return new MaterialPageRoute<dynamic>(
builder: builder,
settings: settings,
);
......
......@@ -106,7 +106,7 @@ void main() {
return new Builder(
builder: (BuildContext context) {
++buildCounter;
return new Container();
return const Text('Y');
},
);
},
......@@ -129,6 +129,7 @@ void main() {
expect(buildCounter, 1);
await tester.pump(const Duration(seconds: 1));
expect(buildCounter, 2);
expect(find.text('Y'), findsOneWidget);
});
testWidgets('Cannot pop the initial route', (WidgetTester tester) async {
......@@ -171,6 +172,46 @@ void main() {
expect(find.text('route "/b"'), findsNothing);
});
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>{
'/': (BuildContext context) => const Text('route "/"'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment