Commit 9b9ad3db authored by Adam Barth's avatar Adam Barth

[rename fixit] RouteBuilder -> BuildContext

Fixes #2353
parent f1331486
......@@ -462,8 +462,8 @@ class CardCollectionState extends State<CardCollection> {
void main() {
runApp(new MaterialApp(
title: 'Cards',
routes: <String, RouteBuilder>{
'/': (RouteArguments args) => new CardCollection(),
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => new CardCollection(),
}
));
}
......@@ -283,8 +283,8 @@ class DragAndDropAppState extends State<DragAndDropApp> {
void main() {
runApp(new MaterialApp(
title: 'Drag and Drop Flutter Demo',
routes: <String, RouteBuilder>{
'/': (RouteArguments args) => new DragAndDropApp()
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => new DragAndDropApp()
}
));
}
......@@ -238,6 +238,6 @@ class _WindowManagerState extends State<WindowManager> {
void main() {
runApp(new MaterialApp(
title: 'Mozart',
routes: <String, RouteBuilder>{ '/': (_) => new WindowManager() }
routes: <String, WidgetBuilder>{ '/': (_) => new WindowManager() }
));
}
......@@ -179,8 +179,8 @@ void main() {
accentColor: Colors.redAccent[200]
),
title: 'Cards',
routes: <String, RouteBuilder>{
'/': (RouteArguments args) => new OverlayGeometryApp()
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => new OverlayGeometryApp()
}
));
}
......@@ -142,8 +142,8 @@ void main() {
primarySwatch: Colors.blue,
accentColor: Colors.redAccent[200]
),
routes: <String, RouteBuilder>{
'/': (RouteArguments args) => new PageableListApp(),
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => new PageableListApp(),
}
));
}
......@@ -12,8 +12,8 @@ void main() {
runApp(
new MaterialApp(
title: "Hardware Key Demo",
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
toolBar: new ToolBar(
center: new Text("Hardware Key Demo")
......
......@@ -214,8 +214,8 @@ class _GestureDemoState extends State<GestureDemo> {
void main() {
runApp(new MaterialApp(
theme: new ThemeData.dark(),
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
toolBar: new ToolBar(
center: new Text('Gestures Demo')),
......
......@@ -97,8 +97,8 @@ final List<String> _kNames = _initNames();
void main() {
runApp(new MaterialApp(
title: 'Media Query Example',
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
toolBar: new ToolBar(
center: new Text('Media Query Example')
......
......@@ -151,8 +151,8 @@ class SectorAppState extends State<SectorApp> {
return new MaterialApp(
theme: new ThemeData.light(),
title: 'Sector Layout',
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
toolBar: new ToolBar(
center: new Text('Sector Layout in a Widget Tree')
......
......@@ -118,8 +118,8 @@ class _StyledTextDemoState extends State<StyledTextDemo> {
void main() {
runApp(new MaterialApp(
theme: new ThemeData.light(),
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
toolBar: new ToolBar(
center: new Text('Hal and Dave')),
......
......@@ -28,7 +28,7 @@ class GalleryAppState extends State<GalleryApp> {
title: 'Flutter Material Gallery',
theme: lightTheme ? new ThemeData.light() : new ThemeData.dark(),
routes: {
'/': (RouteArguments args) => new GalleryHome()
'/': (BuildContext context) => new GalleryHome()
}
);
}
......
......@@ -114,9 +114,9 @@ class StocksAppState extends State<StocksApp> {
debugShowMaterialGrid: _configuration.debugShowGrid,
showPerformanceOverlay: _configuration.showPerformanceOverlay,
showSemanticsDebugger: _configuration.showSemanticsDebugger,
routes: <String, RouteBuilder>{
'/': (RouteArguments args) => new StockHome(_stocks, _symbols, _configuration, configurationUpdater),
'/settings': (RouteArguments args) => new StockSettings(_configuration, configurationUpdater)
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => new StockHome(_stocks, _symbols, _configuration, configurationUpdater),
'/settings': (BuildContext context) => new StockSettings(_configuration, configurationUpdater)
},
onGenerateRoute: _getRoute,
onLocaleChanged: _onLocaleChanged
......
......@@ -28,7 +28,7 @@ class MaterialApp extends WidgetsApp {
Key key,
String title,
ThemeData theme,
Map<String, RouteBuilder> routes: const <String, RouteBuilder>{},
Map<String, WidgetBuilder> routes: const <String, WidgetBuilder>{},
RouteFactory onGenerateRoute,
LocaleChangedCallback onLocaleChanged,
this.debugShowMaterialGrid: false,
......@@ -43,12 +43,10 @@ class MaterialApp extends WidgetsApp {
color: theme?.primaryColor ?? Colors.blue[500], // blue[500] is the primary color of the default theme
routes: routes,
onGenerateRoute: (RouteSettings settings) {
RouteBuilder builder = routes[settings.name];
WidgetBuilder builder = routes[settings.name];
if (builder != null) {
return new MaterialPageRoute<Null>(
builder: (BuildContext context) {
return builder(new RouteArguments(context: context));
},
builder: builder,
settings: settings
);
}
......
......@@ -28,12 +28,6 @@ AssetBundle _initDefaultBundle() {
final AssetBundle _defaultBundle = _initDefaultBundle();
class RouteArguments {
const RouteArguments({ this.context });
final BuildContext context;
}
typedef Widget RouteBuilder(RouteArguments args);
typedef Future<LocaleQueryData> LocaleChangedCallback(Locale locale);
class WidgetsApp extends StatefulWidget {
......@@ -42,7 +36,7 @@ class WidgetsApp extends StatefulWidget {
this.title,
this.textStyle,
this.color,
this.routes: const <String, RouteBuilder>{},
this.routes: const <String, WidgetBuilder>{},
this.onGenerateRoute,
this.onLocaleChanged,
this.showPerformanceOverlay: false,
......@@ -72,7 +66,7 @@ class WidgetsApp extends StatefulWidget {
/// [Navigator] is given a named route, the name will be looked up
/// in this table first. If the name is not available, then
/// [onGenerateRoute] will be called instead.
final Map<String, RouteBuilder> routes;
final Map<String, WidgetBuilder> routes;
/// The route generator callback used when the app is navigated to a
/// named route but the name is not in the [routes] table.
......
......@@ -14,8 +14,8 @@ void main() {
int buildCount = 0;
tester.pumpWidget(new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
key: scaffoldKey,
body: new Center(child: new Text('body'))
......
......@@ -14,9 +14,9 @@ void main() {
bool showBottomSheetThenCalled = false;
tester.pumpWidget(new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
context = args.context;
routes: <String, WidgetBuilder>{
'/': (BuildContext ctx) {
context = ctx;
return new Container();
}
}
......@@ -66,8 +66,8 @@ void main() {
bool showBottomSheetThenCalled = false;
tester.pumpWidget(new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
key: scaffoldKey,
body: new Center(child: new Text('body'))
......
......@@ -12,8 +12,8 @@ void main() {
List<dynamic> accepted = <dynamic>[];
tester.pumpWidget(new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) { return new Column(
routes: <String, WidgetBuilder>{
'/': (BuildContext context) { return new Column(
children: <Widget>[
new Draggable<int>(
data: 1,
......@@ -75,8 +75,8 @@ void main() {
Point firstLocation, secondLocation;
tester.pumpWidget(new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) { return new Column(
routes: <String, WidgetBuilder>{
'/': (BuildContext context) { return new Column(
children: <Widget>[
new Draggable<int>(
data: 1,
......@@ -173,8 +173,8 @@ void main() {
Point firstLocation, secondLocation;
tester.pumpWidget(new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) { return new Column(
routes: <String, WidgetBuilder>{
'/': (BuildContext context) { return new Column(
children: <Widget>[
new Draggable<int>(
data: 1,
......@@ -234,8 +234,8 @@ void main() {
Point firstLocation, secondLocation;
tester.pumpWidget(new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) { return new Column(
routes: <String, WidgetBuilder>{
'/': (BuildContext context) { return new Column(
children: <Widget>[
new LongPressDraggable<int>(
data: 1,
......@@ -285,8 +285,8 @@ void main() {
Point firstLocation, secondLocation;
tester.pumpWidget(new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) { return new Column(
routes: <String, WidgetBuilder>{
'/': (BuildContext context) { return new Column(
children: <Widget>[
new Draggable<int>(
data: 1,
......@@ -337,8 +337,8 @@ void main() {
Point firstLocation, secondLocation, thirdLocation;
tester.pumpWidget(new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Block(
children: <Widget>[
new DragTarget<int>(
......@@ -448,8 +448,8 @@ void main() {
Point firstLocation, secondLocation, thirdLocation;
tester.pumpWidget(new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Block(
scrollDirection: Axis.horizontal,
children: <Widget>[
......
......@@ -15,9 +15,9 @@ void main() {
BuildContext context;
tester.pumpWidget(
new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
context = args.context;
routes: <String, WidgetBuilder>{
'/': (BuildContext ctx) {
context = ctx;
return new Scaffold(
key: scaffoldKey,
drawer: new Text('drawer'),
......@@ -48,8 +48,8 @@ void main() {
tester.pumpWidget(new Container()); // throw away the old App and its Navigator
tester.pumpWidget(
new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
key: scaffoldKey,
drawer: new Text('drawer'),
......
......@@ -12,21 +12,21 @@ Key firstKey = new Key('first');
Key secondKey = new Key('second');
Key thirdKey = new Key('third');
final Map<String, RouteBuilder> routes = <String, RouteBuilder>{
'/': (RouteArguments args) => new Material(
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => new Material(
child: new Block(children: <Widget>[
new Container(height: 100.0, width: 100.0),
new Card(child: new Hero(tag: 'a', child: new Container(height: 100.0, width: 100.0, key: firstKey))),
new Container(height: 100.0, width: 100.0),
new FlatButton(child: new Text('two'), onPressed: () => Navigator.pushNamed(args.context, '/two')),
new FlatButton(child: new Text('two'), onPressed: () => Navigator.pushNamed(context, '/two')),
])
),
'/two': (RouteArguments args) => new Material(
'/two': (BuildContext context) => new Material(
child: new Block(children: <Widget>[
new Container(height: 150.0, width: 150.0),
new Card(child: new Hero(tag: 'a', child: new Container(height: 150.0, width: 150.0, key: secondKey))),
new Container(height: 150.0, width: 150.0),
new FlatButton(child: new Text('three'), onPressed: () => Navigator.push(args.context, new ThreeRoute())),
new FlatButton(child: new Text('three'), onPressed: () => Navigator.push(context, new ThreeRoute())),
])
),
};
......
......@@ -61,9 +61,9 @@ void main() {
test('ModalBarrier pops the Navigator when dismissed', () {
testWidgets((WidgetTester tester) {
final Map<String, RouteBuilder> routes = <String, RouteBuilder>{
'/': (RouteArguments args) => new FirstWidget(),
'/modal': (RouteArguments args) => new SecondWidget(),
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => new FirstWidget(),
'/modal': (BuildContext context) => new SecondWidget(),
};
tester.pumpWidget(new MaterialApp(routes: routes));
......
......@@ -66,9 +66,9 @@ class ThirdWidget extends StatelessWidget {
void main() {
test('Can navigator navigate to and from a stateful widget', () {
testWidgets((WidgetTester tester) {
final Map<String, RouteBuilder> routes = <String, RouteBuilder>{
'/': (RouteArguments args) => new FirstWidget(),
'/second': (RouteArguments args) => new SecondWidget(),
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => new FirstWidget(),
'/second': (BuildContext context) => new SecondWidget(),
};
tester.pumpWidget(new MaterialApp(routes: routes));
......
......@@ -18,7 +18,7 @@ void main() {
testWidgets((WidgetTester tester) {
GlobalKey containerKey1 = new GlobalKey();
GlobalKey containerKey2 = new GlobalKey();
final Map<String, RouteBuilder> routes = <String, RouteBuilder>{
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (_) => new Container(key: containerKey1, child: new Text('Home')),
'/settings': (_) => new Container(key: containerKey2, child: new Text('Settings')),
};
......
......@@ -12,8 +12,8 @@ void main() {
String helloSnackBar = 'Hello SnackBar';
Key tapTarget = new Key('tap-target');
tester.pumpWidget(new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
body: new Builder(
builder: (BuildContext context) {
......@@ -63,8 +63,8 @@ void main() {
int snackBarCount = 0;
Key tapTarget = new Key('tap-target');
tester.pumpWidget(new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
body: new Builder(
builder: (BuildContext context) {
......@@ -146,8 +146,8 @@ void main() {
int time;
ScaffoldFeatureController<SnackBar, Null> lastController;
tester.pumpWidget(new MaterialApp(
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
body: new Builder(
builder: (BuildContext context) {
......
......@@ -13,7 +13,7 @@ void main() {
final Key sublistKey = new UniqueKey();
final Key bottomKey = new UniqueKey();
final Map<String, RouteBuilder> routes = <String, RouteBuilder>{
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (_) {
return new Material(
child: new Viewport(
......
......@@ -29,8 +29,8 @@ Enjoy!
void main() {
runApp(new MaterialApp(
title: "Markdown Demo",
routes: <String, RouteBuilder>{
'/': (RouteArguments args) => new Scaffold(
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => new Scaffold(
toolBar: new ToolBar(center: new Text("Markdown Demo")),
body: new Markdown(data: _kMarkdownData)
)
......
......@@ -12,8 +12,8 @@ void main() {
runApp(
new MaterialApp(
title: 'Flutter Demo',
routes: <String, RouteBuilder>{
'/': (RouteArguments args) => new FlutterDemo()
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => new FlutterDemo()
}
)
);
......
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