forked from firka/flutter
Simplify the usage of Navigator's routes argument
(These are changes cherry-picked from in-flight branches since they are more independent and could be helpful even without those changes.) - Change RouteBuilder's signature to take a single argument in which the other fields are placed, so that we can keep iterating on those arguments without having to break compatibility each time. Also, this makes defining route builders much simpler (only one argument to ignore rather than a variable number). - Expose the next performance to RouteBuilders, since sometimes the route itself might not be where it's used. - Allow BuildContext to be used to walk children, just like it can for ancestors - Allow BuildContext to be used to get the Widget of the current BuildContext - Allow StatefulComponentElement to be referenced with a type specialisation so that you don't have to cast when you know what the type you're dealing with actually is.
This commit is contained in:
@@ -13,9 +13,9 @@ void main() {
|
||||
|
||||
tester.pumpWidget(new Navigator(
|
||||
routes: {
|
||||
'/': (NavigatorState navigator, Route route) { return new Column([
|
||||
'/': (RouteArguments args) { return new Column([
|
||||
new Draggable(
|
||||
navigator: navigator,
|
||||
navigator: args.navigator,
|
||||
data: 1,
|
||||
child: new Text('Source'),
|
||||
feedback: new Text('Dragging')
|
||||
|
||||
@@ -49,8 +49,8 @@ void main() {
|
||||
test('Can navigator navigate to and from a stateful component', () {
|
||||
testWidgets((WidgetTester tester) {
|
||||
final Map<String, RouteBuilder> routes = <String, RouteBuilder>{
|
||||
'/': (navigator, route) => new FirstComponent(navigator),
|
||||
'/second': (navigator, route) => new SecondComponent(navigator),
|
||||
'/': (RouteArguments args) => new FirstComponent(args.navigator),
|
||||
'/second': (RouteArguments args) => new SecondComponent(args.navigator),
|
||||
};
|
||||
|
||||
tester.pumpWidget(new Navigator(routes: routes));
|
||||
|
||||
Reference in New Issue
Block a user