Switch to Navigator2

This commit is contained in:
Adam Barth
2015-10-29 17:09:13 -07:00
parent b003fc898d
commit 50a177b7aa
22 changed files with 513 additions and 1259 deletions

View File

@@ -24,22 +24,20 @@ class StockHomeState extends State<StockHome> {
String _searchQuery;
void _handleSearchBegin() {
Navigator.of(context).pushState(this, (_) {
setState(() {
_isSearching = false;
_searchQuery = null;
});
});
Navigator.of(context).push(new StateRoute(
onPop: () {
setState(() {
_isSearching = false;
_searchQuery = null;
});
}
));
setState(() {
_isSearching = true;
});
}
void _handleSearchEnd() {
assert(() {
final StateRoute currentRoute = Navigator.of(context).currentRoute;
return currentRoute.owner == this;
});
Navigator.of(context).pop();
}

View File

@@ -4,8 +4,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/navigator2.dart' as n2;
class Home extends StatelessComponent {
Widget build(BuildContext context) {
return new Container(
@@ -15,11 +13,11 @@ class Home extends StatelessComponent {
new Text("You are at home"),
new RaisedButton(
child: new Text('GO SHOPPING'),
onPressed: () => n2.Navigator.of(context).pushNamed('/shopping')
onPressed: () => Navigator.of(context).pushNamed('/shopping')
),
new RaisedButton(
child: new Text('START ADVENTURE'),
onPressed: () => n2.Navigator.of(context).pushNamed('/adventure')
onPressed: () => Navigator.of(context).pushNamed('/adventure')
)],
justifyContent: FlexJustifyContent.center
)
@@ -36,11 +34,11 @@ class Shopping extends StatelessComponent {
new Text("Village Shop"),
new RaisedButton(
child: new Text('RETURN HOME'),
onPressed: () => n2.Navigator.of(context).pop()
onPressed: () => Navigator.of(context).pop()
),
new RaisedButton(
child: new Text('GO TO DUNGEON'),
onPressed: () => n2.Navigator.of(context).pushNamed('/adventure')
onPressed: () => Navigator.of(context).pushNamed('/adventure')
)],
justifyContent: FlexJustifyContent.center
)
@@ -57,7 +55,7 @@ class Adventure extends StatelessComponent {
new Text("Monster's Lair"),
new RaisedButton(
child: new Text('RUN!!!'),
onPressed: () => n2.Navigator.of(context).pop()
onPressed: () => Navigator.of(context).pop()
)],
justifyContent: FlexJustifyContent.center
)