Route refactor

- Removed the concept of ephemeral routes.
- Renamed the two _MenuRoutes to _PopupMenuRoute and _DropDownRoute.
- Added type arguments in various places:
  - DropDownMenu
  - _DropDownRoute
  - _ModalBottomSheetRoute
  - PopupMenuItem
  - _PopupMenu
  - _PopupMenuRoute
- Made _ModalBottomSheetRoute, the two ex _MenuRoutes, and _DialogRoute
  all inherit from ModalRoute, via PopupRoute.
- Change "Dropdown" and "DropDown" to "DropDown" consistently.
- Made MaterialPageRoute inherit from PageRoute.
- Made ModalBarrier not create a box if it's always transparent.
- Exposed the Futures on TransitionRoutes.
- Fixed that menus were no longer dismissable by tapping the modal
  barrier.
This commit is contained in:
Hixie
2015-11-17 15:25:29 -08:00
parent de77264749
commit 6e371875e9
11 changed files with 144 additions and 153 deletions

View File

@@ -4,24 +4,22 @@
import 'package:flutter/material.dart';
class DropdownDemo extends StatefulComponent {
DropdownDemo();
DropdownDemoState createState() => new DropdownDemoState();
class DropDownDemo extends StatefulComponent {
DropDownDemoState createState() => new DropDownDemoState();
}
class DropdownDemoState extends State<DropdownDemo> {
class DropDownDemoState extends State<DropDownDemo> {
String _value = "Free";
List<DropdownMenuItem> _buildItems() {
List<DropDownMenuItem<String>> _buildItems() {
return ["One", "Two", "Free", "Four"].map((String value) {
return new DropdownMenuItem<String>(value: value, child: new Text(value));
return new DropDownMenuItem<String>(value: value, child: new Text(value));
})
.toList();
}
Widget build(BuildContext context) {
Widget dropdown = new DropdownButton<String>(
Widget dropdown = new DropDownButton<String>(
items: _buildItems(),
value: _value,
onChanged: (String newValue) {
@@ -33,7 +31,7 @@ class DropdownDemoState extends State<DropdownDemo> {
);
return new Scaffold(
toolBar: new ToolBar(center: new Text('DropdownDemo Demo')),
toolBar: new ToolBar(center: new Text('DropDownDemo Demo')),
body: new Container(
decoration: new BoxDecoration(backgroundColor: Theme.of(context).primarySwatch[50]),
child: new Center(child: dropdown)
@@ -44,14 +42,14 @@ class DropdownDemoState extends State<DropdownDemo> {
void main() {
runApp(new MaterialApp(
title: 'DropdownDemo',
title: 'DropDownDemo',
theme: new ThemeData(
brightness: ThemeBrightness.light,
primarySwatch: Colors.blue,
accentColor: Colors.redAccent[200]
),
routes: <String, RouteBuilder>{
'/': (RouteArguments args) => new DropdownDemo(),
'/': (RouteArguments args) => new DropDownDemo(),
}
));
}