forked from firka/flutter
Add Navigator.of
Now you don't need to pass the navigator around everywhere.
This commit is contained in:
@@ -19,10 +19,6 @@ class CardModel {
|
||||
}
|
||||
|
||||
class CardCollection extends StatefulComponent {
|
||||
CardCollection({ this.navigator });
|
||||
|
||||
final NavigatorState navigator;
|
||||
|
||||
CardCollectionState createState() => new CardCollectionState();
|
||||
}
|
||||
|
||||
@@ -113,7 +109,7 @@ class CardCollectionState extends State<CardCollection> {
|
||||
|
||||
void _showDrawer() {
|
||||
showDrawer(
|
||||
navigator: config.navigator,
|
||||
context: context,
|
||||
child: new IconTheme(
|
||||
data: const IconThemeData(color: IconThemeColor.black),
|
||||
child: new Block([
|
||||
@@ -169,7 +165,7 @@ class CardCollectionState extends State<CardCollection> {
|
||||
setState(() {
|
||||
_dismissDirection = newDismissDirection;
|
||||
});
|
||||
config.navigator.pop();
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
Widget buildDrawerCheckbox(String label, bool value, Function callback) {
|
||||
@@ -374,7 +370,7 @@ void main() {
|
||||
runApp(new MaterialApp(
|
||||
title: 'Cards',
|
||||
routes: {
|
||||
'/': (RouteArguments args) => new CardCollection(navigator: args.navigator),
|
||||
'/': (RouteArguments args) => new CardCollection(),
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
@@ -6,10 +6,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
class IndexedStackDemo extends StatefulComponent {
|
||||
IndexedStackDemo({ this.navigator });
|
||||
|
||||
final NavigatorState navigator;
|
||||
|
||||
IndexedStackDemoState createState() => new IndexedStackDemoState();
|
||||
}
|
||||
|
||||
@@ -23,7 +19,7 @@ class IndexedStackDemoState extends State<IndexedStackDemo> {
|
||||
});
|
||||
}
|
||||
|
||||
List <PopupMenuItem> _buildMenu(NavigatorState navigator) {
|
||||
List <PopupMenuItem> _buildMenu() {
|
||||
TextStyle style = const TextStyle(fontSize: 18.0, fontWeight: bold);
|
||||
String pad = '';
|
||||
return new List.generate(_itemCount, (int i) {
|
||||
@@ -33,7 +29,7 @@ class IndexedStackDemoState extends State<IndexedStackDemo> {
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
List <PopupMenuItem> items = _buildMenu(config.navigator);
|
||||
List <PopupMenuItem> items = _buildMenu();
|
||||
IndexedStack indexedStack = new IndexedStack(items, index: _itemIndex, horizontalAlignment: 0.5);
|
||||
|
||||
return new Scaffold(
|
||||
@@ -61,7 +57,7 @@ void main() {
|
||||
accentColor: Colors.redAccent[200]
|
||||
),
|
||||
routes: {
|
||||
'/': (RouteArguments args) => new IndexedStackDemo(navigator: args.navigator),
|
||||
'/': (RouteArguments args) => new IndexedStackDemo(),
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
@@ -15,10 +15,6 @@ class CardModel {
|
||||
}
|
||||
|
||||
class PageableListApp extends StatefulComponent {
|
||||
PageableListApp({ this.navigator });
|
||||
|
||||
final NavigatorState navigator;
|
||||
|
||||
PageableListAppState createState() => new PageableListAppState();
|
||||
}
|
||||
|
||||
@@ -89,7 +85,7 @@ class PageableListAppState extends State<PageableListApp> {
|
||||
|
||||
void _showDrawer() {
|
||||
showDrawer(
|
||||
navigator: config.navigator,
|
||||
context: context,
|
||||
child: new Block([
|
||||
new DrawerHeader(child: new Text('Options')),
|
||||
new DrawerItem(
|
||||
@@ -161,7 +157,7 @@ void main() {
|
||||
accentColor: Colors.redAccent[200]
|
||||
),
|
||||
routes: {
|
||||
'/': (RouteArguments args) => new PageableListApp(navigator: args.navigator),
|
||||
'/': (RouteArguments args) => new PageableListApp(),
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
@@ -6,10 +6,6 @@ import 'package:intl/intl.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ScrollbarApp extends StatefulComponent {
|
||||
ScrollbarApp({ this.navigator });
|
||||
|
||||
final NavigatorState navigator;
|
||||
|
||||
ScrollbarAppState createState() => new ScrollbarAppState();
|
||||
}
|
||||
|
||||
@@ -65,7 +61,7 @@ void main() {
|
||||
accentColor: Colors.redAccent[200]
|
||||
),
|
||||
routes: {
|
||||
'/': (RouteArguments args) => new ScrollbarApp(navigator: args.navigator),
|
||||
'/': (RouteArguments args) => new ScrollbarApp(),
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user