Unnecessary new (#20138)
* enable lint unnecessary_new * fix tests * fix tests * fix tests
This commit is contained in:
committed by
GitHub
parent
d7a0dcaa4a
commit
d927c93310
@@ -33,18 +33,18 @@ void logMessage(String s) { print(s); }
|
||||
void logError(String s) { print(s); }
|
||||
|
||||
File inputFile(String dir, String name) {
|
||||
return new File(dir + Platform.pathSeparator + name);
|
||||
return File(dir + Platform.pathSeparator + name);
|
||||
}
|
||||
|
||||
File outputFile(String name, [Directory directory]) {
|
||||
return new File((directory ?? outputDirectory).path + Platform.pathSeparator + name);
|
||||
return File((directory ?? outputDirectory).path + Platform.pathSeparator + name);
|
||||
}
|
||||
|
||||
void initialize() {
|
||||
outputDirectory = new Directory('.generated');
|
||||
sampleDirectory = new Directory('lib');
|
||||
testDirectory = new Directory('test');
|
||||
driverDirectory = new Directory('test_driver');
|
||||
outputDirectory = Directory('.generated');
|
||||
sampleDirectory = Directory('lib');
|
||||
testDirectory = Directory('test');
|
||||
driverDirectory = Directory('test_driver');
|
||||
outputDirectory.createSync();
|
||||
}
|
||||
|
||||
@@ -52,10 +52,10 @@ void initialize() {
|
||||
// by values[foo].
|
||||
String expandTemplate(String template, Map<String, String> values) {
|
||||
// Matches @(foo), match[1] == 'foo'
|
||||
final RegExp tokenRE = new RegExp(r'@\(([\w ]+)\)', multiLine: true);
|
||||
final RegExp tokenRE = RegExp(r'@\(([\w ]+)\)', multiLine: true);
|
||||
return template.replaceAllMapped(tokenRE, (Match match) {
|
||||
if (match.groupCount != 1)
|
||||
throw new SampleError('bad template keyword $match[0]');
|
||||
throw SampleError('bad template keyword $match[0]');
|
||||
final String keyword = match[1];
|
||||
return values[keyword] ?? '';
|
||||
});
|
||||
@@ -102,8 +102,8 @@ class SampleInfo {
|
||||
bool initialize() {
|
||||
final String contents = sourceFile.readAsStringSync();
|
||||
|
||||
final RegExp startRE = new RegExp(r'^/\*\s+^Sample\s+Catalog', multiLine: true);
|
||||
final RegExp endRE = new RegExp(r'^\*/', multiLine: true);
|
||||
final RegExp startRE = RegExp(r'^/\*\s+^Sample\s+Catalog', multiLine: true);
|
||||
final RegExp endRE = RegExp(r'^\*/', multiLine: true);
|
||||
final Match startMatch = startRE.firstMatch(contents);
|
||||
if (startMatch == null)
|
||||
return false;
|
||||
@@ -116,12 +116,12 @@ class SampleInfo {
|
||||
final String comment = contents.substring(startIndex, startIndex + endMatch.start);
|
||||
sourceCode = contents.substring(0, startMatch.start) + contents.substring(startIndex + endMatch.end);
|
||||
if (sourceCode.trim().isEmpty)
|
||||
throw new SampleError('did not find any source code in $sourceFile');
|
||||
throw SampleError('did not find any source code in $sourceFile');
|
||||
|
||||
final RegExp keywordsRE = new RegExp(sampleCatalogKeywords, multiLine: true);
|
||||
final RegExp keywordsRE = RegExp(sampleCatalogKeywords, multiLine: true);
|
||||
final List<Match> keywordMatches = keywordsRE.allMatches(comment).toList();
|
||||
if (keywordMatches.isEmpty)
|
||||
throw new SampleError('did not find any keywords in the Sample Catalog comment in $sourceFile');
|
||||
throw SampleError('did not find any keywords in the Sample Catalog comment in $sourceFile');
|
||||
|
||||
commentValues = <String, String>{};
|
||||
for (int i = 0; i < keywordMatches.length; i += 1) {
|
||||
@@ -148,7 +148,7 @@ void generate(String commit) {
|
||||
final List<SampleInfo> samples = <SampleInfo>[];
|
||||
for (FileSystemEntity entity in sampleDirectory.listSync()) {
|
||||
if (entity is File && entity.path.endsWith('.dart')) {
|
||||
final SampleInfo sample = new SampleInfo(entity, commit);
|
||||
final SampleInfo sample = SampleInfo(entity, commit);
|
||||
if (sample.initialize()) // skip files that lack the Sample Catalog comment
|
||||
samples.add(sample);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import 'package:flutter/material.dart';
|
||||
|
||||
class AnimatedListSample extends StatefulWidget {
|
||||
@override
|
||||
_AnimatedListSampleState createState() => new _AnimatedListSampleState();
|
||||
_AnimatedListSampleState createState() => _AnimatedListSampleState();
|
||||
}
|
||||
|
||||
class _AnimatedListSampleState extends State<AnimatedListSample> {
|
||||
final GlobalKey<AnimatedListState> _listKey = new GlobalKey<AnimatedListState>();
|
||||
final GlobalKey<AnimatedListState> _listKey = GlobalKey<AnimatedListState>();
|
||||
ListModel<int> _list;
|
||||
int _selectedItem;
|
||||
int _nextItem; // The next item inserted when the user presses the '+' button.
|
||||
@@ -19,7 +19,7 @@ class _AnimatedListSampleState extends State<AnimatedListSample> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_list = new ListModel<int>(
|
||||
_list = ListModel<int>(
|
||||
listKey: _listKey,
|
||||
initialItems: <int>[0, 1, 2],
|
||||
removedItemBuilder: _buildRemovedItem,
|
||||
@@ -29,7 +29,7 @@ class _AnimatedListSampleState extends State<AnimatedListSample> {
|
||||
|
||||
// Used to build list items that haven't been removed.
|
||||
Widget _buildItem(BuildContext context, int index, Animation<double> animation) {
|
||||
return new CardItem(
|
||||
return CardItem(
|
||||
animation: animation,
|
||||
item: _list[index],
|
||||
selected: _selectedItem == _list[index],
|
||||
@@ -47,7 +47,7 @@ class _AnimatedListSampleState extends State<AnimatedListSample> {
|
||||
// The widget will be used by the [AnimatedListState.removeItem] method's
|
||||
// [AnimatedListRemovedItemBuilder] parameter.
|
||||
Widget _buildRemovedItem(int item, BuildContext context, Animation<double> animation) {
|
||||
return new CardItem(
|
||||
return CardItem(
|
||||
animation: animation,
|
||||
item: item,
|
||||
selected: false,
|
||||
@@ -73,26 +73,26 @@ class _AnimatedListSampleState extends State<AnimatedListSample> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
home: new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('AnimatedList'),
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add_circle),
|
||||
onPressed: _insert,
|
||||
tooltip: 'insert a new item',
|
||||
),
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.remove_circle),
|
||||
onPressed: _remove,
|
||||
tooltip: 'remove the selected item',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: new Padding(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: new AnimatedList(
|
||||
child: AnimatedList(
|
||||
key: _listKey,
|
||||
initialItemCount: _list.length,
|
||||
itemBuilder: _buildItem,
|
||||
@@ -119,7 +119,7 @@ class ListModel<E> {
|
||||
Iterable<E> initialItems,
|
||||
}) : assert(listKey != null),
|
||||
assert(removedItemBuilder != null),
|
||||
_items = new List<E>.from(initialItems ?? <E>[]);
|
||||
_items = List<E>.from(initialItems ?? <E>[]);
|
||||
|
||||
final GlobalKey<AnimatedListState> listKey;
|
||||
final dynamic removedItemBuilder;
|
||||
@@ -173,20 +173,20 @@ class CardItem extends StatelessWidget {
|
||||
TextStyle textStyle = Theme.of(context).textTheme.display1;
|
||||
if (selected)
|
||||
textStyle = textStyle.copyWith(color: Colors.lightGreenAccent[400]);
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(2.0),
|
||||
child: new SizeTransition(
|
||||
child: SizeTransition(
|
||||
axis: Axis.vertical,
|
||||
sizeFactor: animation,
|
||||
child: new GestureDetector(
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: onTap,
|
||||
child: new SizedBox(
|
||||
child: SizedBox(
|
||||
height: 128.0,
|
||||
child: new Card(
|
||||
child: Card(
|
||||
color: Colors.primaries[item % Colors.primaries.length],
|
||||
child: new Center(
|
||||
child: new Text('Item $item', style: textStyle),
|
||||
child: Center(
|
||||
child: Text('Item $item', style: textStyle),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -197,7 +197,7 @@ class CardItem extends StatelessWidget {
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(new AnimatedListSample());
|
||||
runApp(AnimatedListSample());
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
class AppBarBottomSample extends StatefulWidget {
|
||||
@override
|
||||
_AppBarBottomSampleState createState() => new _AppBarBottomSampleState();
|
||||
_AppBarBottomSampleState createState() => _AppBarBottomSampleState();
|
||||
}
|
||||
|
||||
class _AppBarBottomSampleState extends State<AppBarBottomSample> with SingleTickerProviderStateMixin {
|
||||
@@ -15,7 +15,7 @@ class _AppBarBottomSampleState extends State<AppBarBottomSample> with SingleTick
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = new TabController(vsync: this, length: choices.length);
|
||||
_tabController = TabController(vsync: this, length: choices.length);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -33,40 +33,40 @@ class _AppBarBottomSampleState extends State<AppBarBottomSample> with SingleTick
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
home: new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('AppBar Bottom Widget'),
|
||||
leading: new IconButton(
|
||||
leading: IconButton(
|
||||
tooltip: 'Previous choice',
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () { _nextPage(-1); },
|
||||
),
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.arrow_forward),
|
||||
tooltip: 'Next choice',
|
||||
onPressed: () { _nextPage(1); },
|
||||
),
|
||||
],
|
||||
bottom: new PreferredSize(
|
||||
bottom: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(48.0),
|
||||
child: new Theme(
|
||||
child: Theme(
|
||||
data: Theme.of(context).copyWith(accentColor: Colors.white),
|
||||
child: new Container(
|
||||
child: Container(
|
||||
height: 48.0,
|
||||
alignment: Alignment.center,
|
||||
child: new TabPageSelector(controller: _tabController),
|
||||
child: TabPageSelector(controller: _tabController),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
body: new TabBarView(
|
||||
body: TabBarView(
|
||||
controller: _tabController,
|
||||
children: choices.map((Choice choice) {
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: new ChoiceCard(choice: choice),
|
||||
child: ChoiceCard(choice: choice),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
@@ -98,15 +98,15 @@ class ChoiceCard extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final TextStyle textStyle = Theme.of(context).textTheme.display1;
|
||||
return new Card(
|
||||
return Card(
|
||||
color: Colors.white,
|
||||
child: new Center(
|
||||
child: new Column(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
new Icon(choice.icon, size: 128.0, color: textStyle.color),
|
||||
new Text(choice.title, style: textStyle),
|
||||
Icon(choice.icon, size: 128.0, color: textStyle.color),
|
||||
Text(choice.title, style: textStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -115,7 +115,7 @@ class ChoiceCard extends StatelessWidget {
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(new AppBarBottomSample());
|
||||
runApp(AppBarBottomSample());
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
|
||||
// This app is a stateful, it tracks the user's current choice.
|
||||
class BasicAppBarSample extends StatefulWidget {
|
||||
@override
|
||||
_BasicAppBarSampleState createState() => new _BasicAppBarSampleState();
|
||||
_BasicAppBarSampleState createState() => _BasicAppBarSampleState();
|
||||
}
|
||||
|
||||
class _BasicAppBarSampleState extends State<BasicAppBarSample> {
|
||||
@@ -21,35 +21,35 @@ class _BasicAppBarSampleState extends State<BasicAppBarSample> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
home: new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Basic AppBar'),
|
||||
actions: <Widget>[
|
||||
new IconButton( // action button
|
||||
icon: new Icon(choices[0].icon),
|
||||
IconButton( // action button
|
||||
icon: Icon(choices[0].icon),
|
||||
onPressed: () { _select(choices[0]); },
|
||||
),
|
||||
new IconButton( // action button
|
||||
icon: new Icon(choices[1].icon),
|
||||
IconButton( // action button
|
||||
icon: Icon(choices[1].icon),
|
||||
onPressed: () { _select(choices[1]); },
|
||||
),
|
||||
new PopupMenuButton<Choice>( // overflow menu
|
||||
PopupMenuButton<Choice>( // overflow menu
|
||||
onSelected: _select,
|
||||
itemBuilder: (BuildContext context) {
|
||||
return choices.skip(2).map((Choice choice) {
|
||||
return new PopupMenuItem<Choice>(
|
||||
return PopupMenuItem<Choice>(
|
||||
value: choice,
|
||||
child: new Text(choice.title),
|
||||
child: Text(choice.title),
|
||||
);
|
||||
}).toList();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: new Padding(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: new ChoiceCard(choice: _selectedChoice),
|
||||
child: ChoiceCard(choice: _selectedChoice),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -79,15 +79,15 @@ class ChoiceCard extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final TextStyle textStyle = Theme.of(context).textTheme.display1;
|
||||
return new Card(
|
||||
return Card(
|
||||
color: Colors.white,
|
||||
child: new Center(
|
||||
child: new Column(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
new Icon(choice.icon, size: 128.0, color: textStyle.color),
|
||||
new Text(choice.title, style: textStyle),
|
||||
Icon(choice.icon, size: 128.0, color: textStyle.color),
|
||||
Text(choice.title, style: textStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -96,7 +96,7 @@ class ChoiceCard extends StatelessWidget {
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(new BasicAppBarSample());
|
||||
runApp(BasicAppBarSample());
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -76,10 +76,10 @@ class RowColumnTraversal extends StatelessWidget {
|
||||
/// The resulting order is the same.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Semantics(
|
||||
sortKey: new OrdinalSortKey(columnOrder.toDouble()),
|
||||
child: new Semantics(
|
||||
sortKey: new OrdinalSortKey(rowOrder.toDouble()),
|
||||
return Semantics(
|
||||
sortKey: OrdinalSortKey(columnOrder.toDouble()),
|
||||
child: Semantics(
|
||||
sortKey: OrdinalSortKey(rowOrder.toDouble()),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
@@ -111,12 +111,12 @@ class SpinnerButton extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final String label = '${increment ? 'Increment' : 'Decrement'} ${_fieldToName(field)}';
|
||||
|
||||
return new RowColumnTraversal(
|
||||
return RowColumnTraversal(
|
||||
rowOrder: rowOrder,
|
||||
columnOrder: columnOrder,
|
||||
child: new Center(
|
||||
child: new IconButton(
|
||||
icon: new Icon(icon),
|
||||
child: Center(
|
||||
child: IconButton(
|
||||
icon: Icon(icon),
|
||||
onPressed: onPressed,
|
||||
tooltip: label,
|
||||
),
|
||||
@@ -151,17 +151,17 @@ class FieldWidget extends StatelessWidget {
|
||||
final String increasedValue = '${_fieldToName(field)} ${value + 1}';
|
||||
final String decreasedValue = '${_fieldToName(field)} ${value - 1}';
|
||||
|
||||
return new RowColumnTraversal(
|
||||
return RowColumnTraversal(
|
||||
rowOrder: rowOrder,
|
||||
columnOrder: columnOrder,
|
||||
child: new Center(
|
||||
child: new Semantics(
|
||||
child: Center(
|
||||
child: Semantics(
|
||||
onDecrease: onDecrease,
|
||||
onIncrease: onIncrease,
|
||||
value: stringValue,
|
||||
increasedValue: increasedValue,
|
||||
decreasedValue: decreasedValue,
|
||||
child: new ExcludeSemantics(child: new Text(value.toString())),
|
||||
child: ExcludeSemantics(child: Text(value.toString())),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -190,7 +190,7 @@ String _fieldToName(Field field) {
|
||||
/// The top-level example widget that serves as the body of the app.
|
||||
class CustomTraversalExample extends StatefulWidget {
|
||||
@override
|
||||
CustomTraversalExampleState createState() => new CustomTraversalExampleState();
|
||||
CustomTraversalExampleState createState() => CustomTraversalExampleState();
|
||||
}
|
||||
|
||||
/// The state object for the top level example widget.
|
||||
@@ -206,15 +206,15 @@ class CustomTraversalExampleState extends State<CustomTraversalExample> {
|
||||
}
|
||||
|
||||
Widget _makeFieldHeader(int rowOrder, int columnOrder, Field field) {
|
||||
return new RowColumnTraversal(
|
||||
return RowColumnTraversal(
|
||||
rowOrder: rowOrder,
|
||||
columnOrder: columnOrder,
|
||||
child: new Text(_fieldToName(field)),
|
||||
child: Text(_fieldToName(field)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _makeSpinnerButton(int rowOrder, int columnOrder, Field field, {bool increment = true}) {
|
||||
return new SpinnerButton(
|
||||
return SpinnerButton(
|
||||
rowOrder: rowOrder,
|
||||
columnOrder: columnOrder,
|
||||
icon: increment ? Icons.arrow_upward : Icons.arrow_downward,
|
||||
@@ -225,7 +225,7 @@ class CustomTraversalExampleState extends State<CustomTraversalExample> {
|
||||
}
|
||||
|
||||
Widget _makeEntryField(int rowOrder, int columnOrder, Field field) {
|
||||
return new FieldWidget(
|
||||
return FieldWidget(
|
||||
rowOrder: rowOrder,
|
||||
columnOrder: columnOrder,
|
||||
onIncrease: () => _addToField(field, 1),
|
||||
@@ -237,20 +237,20 @@ class CustomTraversalExampleState extends State<CustomTraversalExample> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
home: new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Pet Inventory'),
|
||||
),
|
||||
body: new Builder(
|
||||
body: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return new DefaultTextStyle(
|
||||
return DefaultTextStyle(
|
||||
style: DefaultTextStyle.of(context).style.copyWith(fontSize: 21.0),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
new Semantics(
|
||||
Semantics(
|
||||
// Since this is the only sort key that the text has, it
|
||||
// will be compared with the 'column' OrdinalSortKeys of all the
|
||||
// fields, because the column sort keys are first in the other fields.
|
||||
@@ -262,7 +262,7 @@ class CustomTraversalExampleState extends State<CustomTraversalExample> {
|
||||
),
|
||||
),
|
||||
const Padding(padding: EdgeInsets.symmetric(vertical: 10.0)),
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
_makeFieldHeader(1, 0, Field.DOGS),
|
||||
@@ -270,7 +270,7 @@ class CustomTraversalExampleState extends State<CustomTraversalExample> {
|
||||
_makeFieldHeader(1, 2, Field.FISH),
|
||||
],
|
||||
),
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
_makeSpinnerButton(3, 0, Field.DOGS, increment: true),
|
||||
@@ -278,7 +278,7 @@ class CustomTraversalExampleState extends State<CustomTraversalExample> {
|
||||
_makeSpinnerButton(3, 2, Field.FISH, increment: true),
|
||||
],
|
||||
),
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
_makeEntryField(2, 0, Field.DOGS),
|
||||
@@ -286,7 +286,7 @@ class CustomTraversalExampleState extends State<CustomTraversalExample> {
|
||||
_makeEntryField(2, 2, Field.FISH),
|
||||
],
|
||||
),
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
_makeSpinnerButton(4, 0, Field.DOGS, increment: false),
|
||||
@@ -295,14 +295,14 @@ class CustomTraversalExampleState extends State<CustomTraversalExample> {
|
||||
],
|
||||
),
|
||||
const Padding(padding: EdgeInsets.symmetric(vertical: 10.0)),
|
||||
new Semantics(
|
||||
Semantics(
|
||||
// Since this is the only sort key that the reset button has, it
|
||||
// will be compared with the 'column' OrdinalSortKeys of all the
|
||||
// fields, because the column sort keys are first in the other fields.
|
||||
//
|
||||
// an ordinal of "5.0" means that it will be traversed after column 4.
|
||||
sortKey: const OrdinalSortKey(5.0),
|
||||
child: new MaterialButton(
|
||||
child: MaterialButton(
|
||||
child: const Text('RESET'),
|
||||
textTheme: ButtonTextTheme.normal,
|
||||
textColor: Colors.blue,
|
||||
@@ -324,7 +324,7 @@ class CustomTraversalExampleState extends State<CustomTraversalExample> {
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(new CustomTraversalExample());
|
||||
runApp(CustomTraversalExample());
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -36,7 +36,7 @@ class AdjustableDropdownListTile extends StatelessWidget {
|
||||
final bool canIncrease = indexOfValue < items.length - 1;
|
||||
final bool canDecrease = indexOfValue > 0;
|
||||
|
||||
return new Semantics(
|
||||
return Semantics(
|
||||
container: true,
|
||||
label: label,
|
||||
value: value,
|
||||
@@ -44,16 +44,16 @@ class AdjustableDropdownListTile extends StatelessWidget {
|
||||
decreasedValue: canDecrease ? _decreasedValue : null,
|
||||
onIncrease: canIncrease ? _performIncrease : null,
|
||||
onDecrease: canDecrease ? _performDecrease : null,
|
||||
child: new ExcludeSemantics(
|
||||
child: new ListTile(
|
||||
title: new Text(label),
|
||||
trailing: new DropdownButton<String>(
|
||||
child: ExcludeSemantics(
|
||||
child: ListTile(
|
||||
title: Text(label),
|
||||
trailing: DropdownButton<String>(
|
||||
value: value,
|
||||
onChanged: onChanged,
|
||||
items: items.map((String item) {
|
||||
return new DropdownMenuItem<String>(
|
||||
return DropdownMenuItem<String>(
|
||||
value: item,
|
||||
child: new Text(item),
|
||||
child: Text(item),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
@@ -81,7 +81,7 @@ class AdjustableDropdownListTile extends StatelessWidget {
|
||||
|
||||
class AdjustableDropdownExample extends StatefulWidget {
|
||||
@override
|
||||
AdjustableDropdownExampleState createState() => new AdjustableDropdownExampleState();
|
||||
AdjustableDropdownExampleState createState() => AdjustableDropdownExampleState();
|
||||
}
|
||||
|
||||
class AdjustableDropdownExampleState extends State<AdjustableDropdownExample> {
|
||||
@@ -97,14 +97,14 @@ class AdjustableDropdownExampleState extends State<AdjustableDropdownExample> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
home: new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Adjustable DropDown'),
|
||||
),
|
||||
body: new ListView(
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
new AdjustableDropdownListTile(
|
||||
AdjustableDropdownListTile(
|
||||
label: 'Timeout',
|
||||
value: timeout ?? items[2],
|
||||
items: items,
|
||||
@@ -122,7 +122,7 @@ class AdjustableDropdownExampleState extends State<AdjustableDropdownExample> {
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(new AdjustableDropdownExample());
|
||||
runApp(AdjustableDropdownExample());
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -7,13 +7,13 @@ import 'package:flutter/material.dart';
|
||||
class ExpansionTileSample extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
home: new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('ExpansionTile'),
|
||||
),
|
||||
body: new ListView.builder(
|
||||
itemBuilder: (BuildContext context, int index) => new EntryItem(data[index]),
|
||||
body: ListView.builder(
|
||||
itemBuilder: (BuildContext context, int index) => EntryItem(data[index]),
|
||||
itemCount: data.length,
|
||||
),
|
||||
),
|
||||
@@ -30,35 +30,35 @@ class Entry {
|
||||
|
||||
// The entire multilevel list displayed by this app.
|
||||
final List<Entry> data = <Entry>[
|
||||
new Entry('Chapter A',
|
||||
Entry('Chapter A',
|
||||
<Entry>[
|
||||
new Entry('Section A0',
|
||||
Entry('Section A0',
|
||||
<Entry>[
|
||||
new Entry('Item A0.1'),
|
||||
new Entry('Item A0.2'),
|
||||
new Entry('Item A0.3'),
|
||||
Entry('Item A0.1'),
|
||||
Entry('Item A0.2'),
|
||||
Entry('Item A0.3'),
|
||||
],
|
||||
),
|
||||
new Entry('Section A1'),
|
||||
new Entry('Section A2'),
|
||||
Entry('Section A1'),
|
||||
Entry('Section A2'),
|
||||
],
|
||||
),
|
||||
new Entry('Chapter B',
|
||||
Entry('Chapter B',
|
||||
<Entry>[
|
||||
new Entry('Section B0'),
|
||||
new Entry('Section B1'),
|
||||
Entry('Section B0'),
|
||||
Entry('Section B1'),
|
||||
],
|
||||
),
|
||||
new Entry('Chapter C',
|
||||
Entry('Chapter C',
|
||||
<Entry>[
|
||||
new Entry('Section C0'),
|
||||
new Entry('Section C1'),
|
||||
new Entry('Section C2',
|
||||
Entry('Section C0'),
|
||||
Entry('Section C1'),
|
||||
Entry('Section C2',
|
||||
<Entry>[
|
||||
new Entry('Item C2.0'),
|
||||
new Entry('Item C2.1'),
|
||||
new Entry('Item C2.2'),
|
||||
new Entry('Item C2.3'),
|
||||
Entry('Item C2.0'),
|
||||
Entry('Item C2.1'),
|
||||
Entry('Item C2.2'),
|
||||
Entry('Item C2.3'),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -74,10 +74,10 @@ class EntryItem extends StatelessWidget {
|
||||
|
||||
Widget _buildTiles(Entry root) {
|
||||
if (root.children.isEmpty)
|
||||
return new ListTile(title: new Text(root.title));
|
||||
return new ExpansionTile(
|
||||
key: new PageStorageKey<Entry>(root),
|
||||
title: new Text(root.title),
|
||||
return ListTile(title: Text(root.title));
|
||||
return ExpansionTile(
|
||||
key: PageStorageKey<Entry>(root),
|
||||
title: Text(root.title),
|
||||
children: root.children.map(_buildTiles).toList(),
|
||||
);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ class EntryItem extends StatelessWidget {
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(new ExpansionTileSample());
|
||||
runApp(ExpansionTileSample());
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -7,27 +7,27 @@ import 'package:flutter/material.dart';
|
||||
class TabbedAppBarSample extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
home: new DefaultTabController(
|
||||
return MaterialApp(
|
||||
home: DefaultTabController(
|
||||
length: choices.length,
|
||||
child: new Scaffold(
|
||||
appBar: new AppBar(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Tabbed AppBar'),
|
||||
bottom: new TabBar(
|
||||
bottom: TabBar(
|
||||
isScrollable: true,
|
||||
tabs: choices.map((Choice choice) {
|
||||
return new Tab(
|
||||
return Tab(
|
||||
text: choice.title,
|
||||
icon: new Icon(choice.icon),
|
||||
icon: Icon(choice.icon),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
body: new TabBarView(
|
||||
body: TabBarView(
|
||||
children: choices.map((Choice choice) {
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: new ChoiceCard(choice: choice),
|
||||
child: ChoiceCard(choice: choice),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
@@ -60,15 +60,15 @@ class ChoiceCard extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final TextStyle textStyle = Theme.of(context).textTheme.display1;
|
||||
return new Card(
|
||||
return Card(
|
||||
color: Colors.white,
|
||||
child: new Center(
|
||||
child: new Column(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
new Icon(choice.icon, size: 128.0, color: textStyle.color),
|
||||
new Text(choice.title, style: textStyle),
|
||||
Icon(choice.icon, size: 128.0, color: textStyle.color),
|
||||
Text(choice.title, style: textStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -77,7 +77,7 @@ class ChoiceCard extends StatelessWidget {
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(new TabbedAppBarSample());
|
||||
runApp(TabbedAppBarSample());
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -65,7 +65,7 @@ class _RenderStatusBarPaddingSliver extends RenderSliver {
|
||||
@override
|
||||
void performLayout() {
|
||||
final double height = (maxHeight - constraints.scrollOffset / scrollFactor).clamp(0.0, maxHeight);
|
||||
geometry = new SliverGeometry(
|
||||
geometry = SliverGeometry(
|
||||
paintExtent: math.min(height, constraints.remainingPaintExtent),
|
||||
scrollExtent: maxHeight,
|
||||
maxPaintExtent: maxHeight,
|
||||
@@ -87,7 +87,7 @@ class _StatusBarPaddingSliver extends SingleChildRenderObjectWidget {
|
||||
|
||||
@override
|
||||
_RenderStatusBarPaddingSliver createRenderObject(BuildContext context) {
|
||||
return new _RenderStatusBarPaddingSliver(
|
||||
return _RenderStatusBarPaddingSliver(
|
||||
maxHeight: maxHeight,
|
||||
scrollFactor: scrollFactor,
|
||||
);
|
||||
@@ -103,8 +103,8 @@ class _StatusBarPaddingSliver extends SingleChildRenderObjectWidget {
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder description) {
|
||||
super.debugFillProperties(description);
|
||||
description.add(new DoubleProperty('maxHeight', maxHeight));
|
||||
description.add(new DoubleProperty('scrollFactor', scrollFactor));
|
||||
description.add(DoubleProperty('maxHeight', maxHeight));
|
||||
description.add(DoubleProperty('scrollFactor', scrollFactor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
|
||||
return new SizedBox.expand(child: child);
|
||||
return SizedBox.expand(child: child);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -210,34 +210,34 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate {
|
||||
for (int index = 0; index < cardCount; index++) {
|
||||
|
||||
// Layout the card for index.
|
||||
final Rect columnCardRect = new Rect.fromLTWH(columnCardX, columnCardY, columnCardWidth, columnCardHeight);
|
||||
final Rect rowCardRect = new Rect.fromLTWH(rowCardX, 0.0, rowCardWidth, size.height);
|
||||
final Rect columnCardRect = Rect.fromLTWH(columnCardX, columnCardY, columnCardWidth, columnCardHeight);
|
||||
final Rect rowCardRect = Rect.fromLTWH(rowCardX, 0.0, rowCardWidth, size.height);
|
||||
final Rect cardRect = _interpolateRect(columnCardRect, rowCardRect).shift(offset);
|
||||
final String cardId = 'card$index';
|
||||
if (hasChild(cardId)) {
|
||||
layoutChild(cardId, new BoxConstraints.tight(cardRect.size));
|
||||
layoutChild(cardId, BoxConstraints.tight(cardRect.size));
|
||||
positionChild(cardId, cardRect.topLeft);
|
||||
}
|
||||
|
||||
// Layout the title for index.
|
||||
final Size titleSize = layoutChild('title$index', new BoxConstraints.loose(cardRect.size));
|
||||
final Size titleSize = layoutChild('title$index', BoxConstraints.loose(cardRect.size));
|
||||
final double columnTitleY = columnCardRect.centerLeft.dy - titleSize.height / 2.0;
|
||||
final double rowTitleY = rowCardRect.centerLeft.dy - titleSize.height / 2.0;
|
||||
final double centeredRowTitleX = rowTitleX + (rowTitleWidth - titleSize.width) / 2.0;
|
||||
final Offset columnTitleOrigin = new Offset(columnTitleX, columnTitleY);
|
||||
final Offset rowTitleOrigin = new Offset(centeredRowTitleX, rowTitleY);
|
||||
final Offset columnTitleOrigin = Offset(columnTitleX, columnTitleY);
|
||||
final Offset rowTitleOrigin = Offset(centeredRowTitleX, rowTitleY);
|
||||
final Offset titleOrigin = _interpolatePoint(columnTitleOrigin, rowTitleOrigin);
|
||||
positionChild('title$index', titleOrigin + offset);
|
||||
|
||||
// Layout the selection indicator for index.
|
||||
final Size indicatorSize = layoutChild('indicator$index', new BoxConstraints.loose(cardRect.size));
|
||||
final Size indicatorSize = layoutChild('indicator$index', BoxConstraints.loose(cardRect.size));
|
||||
final double columnIndicatorX = cardRect.centerRight.dx - indicatorSize.width - 16.0;
|
||||
final double columnIndicatorY = cardRect.bottomRight.dy - indicatorSize.height - 16.0;
|
||||
final Offset columnIndicatorOrigin = new Offset(columnIndicatorX, columnIndicatorY);
|
||||
final Rect titleRect = new Rect.fromPoints(titleOrigin, titleSize.bottomRight(titleOrigin));
|
||||
final Offset columnIndicatorOrigin = Offset(columnIndicatorX, columnIndicatorY);
|
||||
final Rect titleRect = Rect.fromPoints(titleOrigin, titleSize.bottomRight(titleOrigin));
|
||||
final double centeredRowIndicatorX = rowIndicatorX + (rowIndicatorWidth - indicatorSize.width) / 2.0;
|
||||
final double rowIndicatorY = titleRect.bottomCenter.dy + 16.0;
|
||||
final Offset rowIndicatorOrigin = new Offset(centeredRowIndicatorX, rowIndicatorY);
|
||||
final Offset rowIndicatorOrigin = Offset(centeredRowIndicatorX, rowIndicatorY);
|
||||
final Offset indicatorOrigin = _interpolatePoint(columnIndicatorOrigin, rowIndicatorOrigin);
|
||||
positionChild('indicator$index', indicatorOrigin + offset);
|
||||
|
||||
@@ -319,13 +319,13 @@ class _AllSectionsView extends AnimatedWidget {
|
||||
return 1.0 - _selectedIndexDelta(index) * tColumnToRow * 0.15;
|
||||
}
|
||||
|
||||
final List<Widget> children = new List<Widget>.from(sectionCards);
|
||||
final List<Widget> children = List<Widget>.from(sectionCards);
|
||||
|
||||
for (int index = 0; index < sections.length; index++) {
|
||||
final Section section = sections[index];
|
||||
children.add(new LayoutId(
|
||||
children.add(LayoutId(
|
||||
id: 'title$index',
|
||||
child: new SectionTitle(
|
||||
child: SectionTitle(
|
||||
section: section,
|
||||
scale: _titleScale(index),
|
||||
opacity: _titleOpacity(index),
|
||||
@@ -334,17 +334,17 @@ class _AllSectionsView extends AnimatedWidget {
|
||||
}
|
||||
|
||||
for (int index = 0; index < sections.length; index++) {
|
||||
children.add(new LayoutId(
|
||||
children.add(LayoutId(
|
||||
id: 'indicator$index',
|
||||
child: new SectionIndicator(
|
||||
child: SectionIndicator(
|
||||
opacity: _indicatorOpacity(index),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
return new CustomMultiChildLayout(
|
||||
delegate: new _AllSectionsLayout(
|
||||
translation: new Alignment((selectedIndex.value - sectionIndex) * 2.0 - 1.0, -1.0),
|
||||
return CustomMultiChildLayout(
|
||||
delegate: _AllSectionsLayout(
|
||||
translation: Alignment((selectedIndex.value - sectionIndex) * 2.0 - 1.0, -1.0),
|
||||
tColumnToRow: tColumnToRow,
|
||||
tCollapsed: tCollapsed,
|
||||
cardCount: sections.length,
|
||||
@@ -356,7 +356,7 @@ class _AllSectionsView extends AnimatedWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new LayoutBuilder(builder: _build);
|
||||
return LayoutBuilder(builder: _build);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,17 +374,17 @@ class _SnappingScrollPhysics extends ClampingScrollPhysics {
|
||||
|
||||
@override
|
||||
_SnappingScrollPhysics applyTo(ScrollPhysics ancestor) {
|
||||
return new _SnappingScrollPhysics(parent: buildParent(ancestor), midScrollOffset: midScrollOffset);
|
||||
return _SnappingScrollPhysics(parent: buildParent(ancestor), midScrollOffset: midScrollOffset);
|
||||
}
|
||||
|
||||
Simulation _toMidScrollOffsetSimulation(double offset, double dragVelocity) {
|
||||
final double velocity = math.max(dragVelocity, minFlingVelocity);
|
||||
return new ScrollSpringSimulation(spring, offset, midScrollOffset, velocity, tolerance: tolerance);
|
||||
return ScrollSpringSimulation(spring, offset, midScrollOffset, velocity, tolerance: tolerance);
|
||||
}
|
||||
|
||||
Simulation _toZeroScrollOffsetSimulation(double offset, double dragVelocity) {
|
||||
final double velocity = math.max(dragVelocity, minFlingVelocity);
|
||||
return new ScrollSpringSimulation(spring, offset, 0.0, velocity, tolerance: tolerance);
|
||||
return ScrollSpringSimulation(spring, offset, 0.0, velocity, tolerance: tolerance);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -425,21 +425,21 @@ class AnimationDemoHome extends StatefulWidget {
|
||||
static const String routeName = '/animation';
|
||||
|
||||
@override
|
||||
_AnimationDemoHomeState createState() => new _AnimationDemoHomeState();
|
||||
_AnimationDemoHomeState createState() => _AnimationDemoHomeState();
|
||||
}
|
||||
|
||||
class _AnimationDemoHomeState extends State<AnimationDemoHome> {
|
||||
final ScrollController _scrollController = new ScrollController();
|
||||
final PageController _headingPageController = new PageController();
|
||||
final PageController _detailsPageController = new PageController();
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
final PageController _headingPageController = PageController();
|
||||
final PageController _detailsPageController = PageController();
|
||||
ScrollPhysics _headingScrollPhysics = const NeverScrollableScrollPhysics();
|
||||
ValueNotifier<double> selectedIndex = new ValueNotifier<double>(0.0);
|
||||
ValueNotifier<double> selectedIndex = ValueNotifier<double>(0.0);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
backgroundColor: _kAppBackgroundColor,
|
||||
body: new Builder(
|
||||
body: Builder(
|
||||
// Insert an element so that _buildBody can find the PrimaryScrollController.
|
||||
builder: _buildBody,
|
||||
),
|
||||
@@ -494,7 +494,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
|
||||
|
||||
Iterable<Widget> _detailItemsFor(Section section) {
|
||||
final Iterable<Widget> detailItems = section.details.map((SectionDetail detail) {
|
||||
return new SectionDetailView(detail: detail);
|
||||
return SectionDetailView(detail: detail);
|
||||
});
|
||||
return ListTile.divideTiles(context: context, tiles: detailItems);
|
||||
}
|
||||
@@ -502,11 +502,11 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
|
||||
Iterable<Widget> _allHeadingItems(double maxHeight, double midScrollOffset) {
|
||||
final List<Widget> sectionCards = <Widget>[];
|
||||
for (int index = 0; index < allSections.length; index++) {
|
||||
sectionCards.add(new LayoutId(
|
||||
sectionCards.add(LayoutId(
|
||||
id: 'card$index',
|
||||
child: new GestureDetector(
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: new SectionCard(section: allSections[index]),
|
||||
child: SectionCard(section: allSections[index]),
|
||||
onTapUp: (TapUpDetails details) {
|
||||
final double xOffset = details.globalPosition.dx;
|
||||
setState(() {
|
||||
@@ -519,10 +519,10 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
|
||||
|
||||
final List<Widget> headings = <Widget>[];
|
||||
for (int index = 0; index < allSections.length; index++) {
|
||||
headings.add(new Container(
|
||||
headings.add(Container(
|
||||
color: _kAppBackgroundColor,
|
||||
child: new ClipRect(
|
||||
child: new _AllSectionsView(
|
||||
child: ClipRect(
|
||||
child: _AllSectionsView(
|
||||
sectionIndex: index,
|
||||
sections: allSections,
|
||||
selectedIndex: selectedIndex,
|
||||
@@ -547,33 +547,33 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
|
||||
// The scroll offset that reveals the appBarMidHeight appbar.
|
||||
final double appBarMidScrollOffset = statusBarHeight + appBarMaxHeight - _kAppBarMidHeight;
|
||||
|
||||
return new SizedBox.expand(
|
||||
child: new Stack(
|
||||
return SizedBox.expand(
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
new NotificationListener<ScrollNotification>(
|
||||
NotificationListener<ScrollNotification>(
|
||||
onNotification: (ScrollNotification notification) {
|
||||
return _handleScrollNotification(notification, appBarMidScrollOffset);
|
||||
},
|
||||
child: new CustomScrollView(
|
||||
child: CustomScrollView(
|
||||
controller: _scrollController,
|
||||
physics: new _SnappingScrollPhysics(midScrollOffset: appBarMidScrollOffset),
|
||||
physics: _SnappingScrollPhysics(midScrollOffset: appBarMidScrollOffset),
|
||||
slivers: <Widget>[
|
||||
// Start out below the status bar, gradually move to the top of the screen.
|
||||
new _StatusBarPaddingSliver(
|
||||
_StatusBarPaddingSliver(
|
||||
maxHeight: statusBarHeight,
|
||||
scrollFactor: 7.0,
|
||||
),
|
||||
// Section Headings
|
||||
new SliverPersistentHeader(
|
||||
SliverPersistentHeader(
|
||||
pinned: true,
|
||||
delegate: new _SliverAppBarDelegate(
|
||||
delegate: _SliverAppBarDelegate(
|
||||
minHeight: _kAppBarMinHeight,
|
||||
maxHeight: appBarMaxHeight,
|
||||
child: new NotificationListener<ScrollNotification>(
|
||||
child: NotificationListener<ScrollNotification>(
|
||||
onNotification: (ScrollNotification notification) {
|
||||
return _handlePageNotification(notification, _headingPageController, _detailsPageController);
|
||||
},
|
||||
child: new PageView(
|
||||
child: PageView(
|
||||
physics: _headingScrollPhysics,
|
||||
controller: _headingPageController,
|
||||
children: _allHeadingItems(appBarMaxHeight, appBarMidScrollOffset),
|
||||
@@ -582,17 +582,17 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
|
||||
),
|
||||
),
|
||||
// Details
|
||||
new SliverToBoxAdapter(
|
||||
child: new SizedBox(
|
||||
SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
height: 610.0,
|
||||
child: new NotificationListener<ScrollNotification>(
|
||||
child: NotificationListener<ScrollNotification>(
|
||||
onNotification: (ScrollNotification notification) {
|
||||
return _handlePageNotification(notification, _detailsPageController, _headingPageController);
|
||||
},
|
||||
child: new PageView(
|
||||
child: PageView(
|
||||
controller: _detailsPageController,
|
||||
children: allSections.map((Section section) {
|
||||
return new Column(
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: _detailItemsFor(section).toList(),
|
||||
);
|
||||
@@ -604,15 +604,15 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
|
||||
],
|
||||
),
|
||||
),
|
||||
new Positioned(
|
||||
Positioned(
|
||||
top: statusBarHeight,
|
||||
left: 0.0,
|
||||
child: new IconTheme(
|
||||
child: IconTheme(
|
||||
data: const IconThemeData(color: Colors.white),
|
||||
child: new SafeArea(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new IconButton(
|
||||
child: IconButton(
|
||||
icon: const BackButtonIcon(),
|
||||
tooltip: 'Back',
|
||||
onPressed: () {
|
||||
|
||||
@@ -18,12 +18,12 @@ class SectionCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Semantics(
|
||||
return Semantics(
|
||||
label: section.title,
|
||||
button: true,
|
||||
child: new DecoratedBox(
|
||||
decoration: new BoxDecoration(
|
||||
gradient: new LinearGradient(
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: <Color>[
|
||||
@@ -32,7 +32,7 @@ class SectionCard extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
child: new Image.asset(
|
||||
child: Image.asset(
|
||||
section.backgroundAsset,
|
||||
package: section.backgroundAssetPackage,
|
||||
color: const Color.fromRGBO(255, 255, 255, 0.075),
|
||||
@@ -76,19 +76,19 @@ class SectionTitle extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new IgnorePointer(
|
||||
child: new Opacity(
|
||||
return IgnorePointer(
|
||||
child: Opacity(
|
||||
opacity: opacity,
|
||||
child: new Transform(
|
||||
transform: new Matrix4.identity()..scale(scale),
|
||||
child: Transform(
|
||||
transform: Matrix4.identity()..scale(scale),
|
||||
alignment: Alignment.center,
|
||||
child: new Stack(
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
new Positioned(
|
||||
Positioned(
|
||||
top: 4.0,
|
||||
child: new Text(section.title, style: sectionTitleShadowStyle),
|
||||
child: Text(section.title, style: sectionTitleShadowStyle),
|
||||
),
|
||||
new Text(section.title, style: sectionTitleStyle),
|
||||
Text(section.title, style: sectionTitleStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -105,8 +105,8 @@ class SectionIndicator extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new IgnorePointer(
|
||||
child: new Container(
|
||||
return IgnorePointer(
|
||||
child: Container(
|
||||
width: kSectionIndicatorWidth,
|
||||
height: 3.0,
|
||||
color: Colors.white.withOpacity(opacity),
|
||||
@@ -126,11 +126,11 @@ class SectionDetailView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Widget image = new DecoratedBox(
|
||||
decoration: new BoxDecoration(
|
||||
borderRadius: new BorderRadius.circular(6.0),
|
||||
image: new DecorationImage(
|
||||
image: new AssetImage(
|
||||
final Widget image = DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(6.0),
|
||||
image: DecorationImage(
|
||||
image: AssetImage(
|
||||
detail.imageAsset,
|
||||
package: detail.imageAssetPackage,
|
||||
),
|
||||
@@ -142,25 +142,25 @@ class SectionDetailView extends StatelessWidget {
|
||||
|
||||
Widget item;
|
||||
if (detail.title == null && detail.subtitle == null) {
|
||||
item = new Container(
|
||||
item = Container(
|
||||
height: 240.0,
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: new SafeArea(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: image,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
item = new ListTile(
|
||||
title: new Text(detail.title),
|
||||
subtitle: new Text(detail.subtitle),
|
||||
leading: new SizedBox(width: 32.0, height: 32.0, child: image),
|
||||
item = ListTile(
|
||||
title: Text(detail.title),
|
||||
subtitle: Text(detail.subtitle),
|
||||
leading: SizedBox(width: 32.0, height: 32.0, child: image),
|
||||
);
|
||||
}
|
||||
|
||||
return new DecoratedBox(
|
||||
decoration: new BoxDecoration(color: Colors.grey.shade200),
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(color: Colors.grey.shade200),
|
||||
child: item,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class Calculator extends StatefulWidget {
|
||||
const Calculator({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_CalculatorState createState() => new _CalculatorState();
|
||||
_CalculatorState createState() => _CalculatorState();
|
||||
}
|
||||
|
||||
class _CalculatorState extends State<Calculator> {
|
||||
@@ -18,7 +18,7 @@ class _CalculatorState extends State<Calculator> {
|
||||
/// keep a stack of previous expressions so we can return to earlier states
|
||||
/// when the user hits the DEL key.
|
||||
final List<CalcExpression> _expressionStack = <CalcExpression>[];
|
||||
CalcExpression _expression = new CalcExpression.empty();
|
||||
CalcExpression _expression = CalcExpression.empty();
|
||||
|
||||
// Make `expression` the current expression and push the previous current
|
||||
// expression onto the stack.
|
||||
@@ -32,7 +32,7 @@ class _CalculatorState extends State<Calculator> {
|
||||
if (_expressionStack.isNotEmpty) {
|
||||
_expression = _expressionStack.removeLast();
|
||||
} else {
|
||||
_expression = new CalcExpression.empty();
|
||||
_expression = CalcExpression.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,23 +113,23 @@ class _CalculatorState extends State<Calculator> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Theme.of(context).canvasColor,
|
||||
elevation: 0.0
|
||||
),
|
||||
body: new Column(
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
// Give the key-pad 3/5 of the vertical space and the display 2/5.
|
||||
new Expanded(
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: new CalcDisplay(content: _expression.toString())
|
||||
child: CalcDisplay(content: _expression.toString())
|
||||
),
|
||||
const Divider(height: 1.0),
|
||||
new Expanded(
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: new KeyPad(calcState: this)
|
||||
child: KeyPad(calcState: this)
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -144,8 +144,8 @@ class CalcDisplay extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Center(
|
||||
child: new Text(
|
||||
return Center(
|
||||
child: Text(
|
||||
content,
|
||||
style: const TextStyle(fontSize: 24.0)
|
||||
)
|
||||
@@ -160,56 +160,56 @@ class KeyPad extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData themeData = new ThemeData(
|
||||
final ThemeData themeData = ThemeData(
|
||||
primarySwatch: Colors.purple,
|
||||
brightness: Brightness.dark,
|
||||
platform: Theme.of(context).platform,
|
||||
);
|
||||
return new Theme(
|
||||
return Theme(
|
||||
data: themeData,
|
||||
child: new Material(
|
||||
child: new Row(
|
||||
child: Material(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
Expanded(
|
||||
// We set flex equal to the number of columns so that the main keypad
|
||||
// and the op keypad have sizes proportional to their number of
|
||||
// columns.
|
||||
flex: 3,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new KeyRow(<Widget>[
|
||||
new NumberKey(7, calcState),
|
||||
new NumberKey(8, calcState),
|
||||
new NumberKey(9, calcState)
|
||||
KeyRow(<Widget>[
|
||||
NumberKey(7, calcState),
|
||||
NumberKey(8, calcState),
|
||||
NumberKey(9, calcState)
|
||||
]),
|
||||
new KeyRow(<Widget>[
|
||||
new NumberKey(4, calcState),
|
||||
new NumberKey(5, calcState),
|
||||
new NumberKey(6, calcState)
|
||||
KeyRow(<Widget>[
|
||||
NumberKey(4, calcState),
|
||||
NumberKey(5, calcState),
|
||||
NumberKey(6, calcState)
|
||||
]),
|
||||
new KeyRow(<Widget>[
|
||||
new NumberKey(1, calcState),
|
||||
new NumberKey(2, calcState),
|
||||
new NumberKey(3, calcState)
|
||||
KeyRow(<Widget>[
|
||||
NumberKey(1, calcState),
|
||||
NumberKey(2, calcState),
|
||||
NumberKey(3, calcState)
|
||||
]),
|
||||
new KeyRow(<Widget>[
|
||||
new CalcKey('.', calcState.handlePointTap),
|
||||
new NumberKey(0, calcState),
|
||||
new CalcKey('=', calcState.handleEqualsTap),
|
||||
KeyRow(<Widget>[
|
||||
CalcKey('.', calcState.handlePointTap),
|
||||
NumberKey(0, calcState),
|
||||
CalcKey('=', calcState.handleEqualsTap),
|
||||
])
|
||||
]
|
||||
)
|
||||
),
|
||||
new Expanded(
|
||||
child: new Material(
|
||||
Expanded(
|
||||
child: Material(
|
||||
color: themeData.backgroundColor,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new CalcKey('\u232B', calcState.handleDelTap),
|
||||
new CalcKey('\u00F7', calcState.handleDivTap),
|
||||
new CalcKey('\u00D7', calcState.handleMultTap),
|
||||
new CalcKey('-', calcState.handleMinusTap),
|
||||
new CalcKey('+', calcState.handlePlusTap)
|
||||
CalcKey('\u232B', calcState.handleDelTap),
|
||||
CalcKey('\u00F7', calcState.handleDivTap),
|
||||
CalcKey('\u00D7', calcState.handleMultTap),
|
||||
CalcKey('-', calcState.handleMinusTap),
|
||||
CalcKey('+', calcState.handlePlusTap)
|
||||
]
|
||||
)
|
||||
)
|
||||
@@ -228,8 +228,8 @@ class KeyRow extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Expanded(
|
||||
child: new Row(
|
||||
return Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: keys
|
||||
)
|
||||
@@ -246,13 +246,13 @@ class CalcKey extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Orientation orientation = MediaQuery.of(context).orientation;
|
||||
return new Expanded(
|
||||
child: new InkResponse(
|
||||
return Expanded(
|
||||
child: InkResponse(
|
||||
onTap: onTap,
|
||||
child: new Center(
|
||||
child: new Text(
|
||||
child: Center(
|
||||
child: Text(
|
||||
text,
|
||||
style: new TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: (orientation == Orientation.portrait) ? 32.0 : 24.0
|
||||
)
|
||||
)
|
||||
|
||||
@@ -138,7 +138,7 @@ class CalcExpression {
|
||||
/// in the calculator's display panel.
|
||||
@override
|
||||
String toString() {
|
||||
final StringBuffer buffer = new StringBuffer('');
|
||||
final StringBuffer buffer = StringBuffer('');
|
||||
buffer.writeAll(_list);
|
||||
return buffer.toString();
|
||||
}
|
||||
@@ -153,29 +153,29 @@ class CalcExpression {
|
||||
switch (state) {
|
||||
case ExpressionState.Start:
|
||||
// Start a new number with digit.
|
||||
newToken = new IntToken('$digit');
|
||||
newToken = IntToken('$digit');
|
||||
break;
|
||||
case ExpressionState.LeadingNeg:
|
||||
// Replace the leading neg with a negative number starting with digit.
|
||||
outList.removeLast();
|
||||
newToken = new IntToken('-$digit');
|
||||
newToken = IntToken('-$digit');
|
||||
break;
|
||||
case ExpressionState.Number:
|
||||
final ExpressionToken last = outList.removeLast();
|
||||
newToken = new IntToken('${last.stringRep}$digit');
|
||||
newToken = IntToken('${last.stringRep}$digit');
|
||||
break;
|
||||
case ExpressionState.Point:
|
||||
case ExpressionState.NumberWithPoint:
|
||||
final ExpressionToken last = outList.removeLast();
|
||||
newState = ExpressionState.NumberWithPoint;
|
||||
newToken = new FloatToken('${last.stringRep}$digit');
|
||||
newToken = FloatToken('${last.stringRep}$digit');
|
||||
break;
|
||||
case ExpressionState.Result:
|
||||
// Cannot enter a number now
|
||||
return null;
|
||||
}
|
||||
outList.add(newToken);
|
||||
return new CalcExpression(outList, newState);
|
||||
return CalcExpression(outList, newState);
|
||||
}
|
||||
|
||||
/// Append a point to the current expression and return a new expression
|
||||
@@ -186,12 +186,12 @@ class CalcExpression {
|
||||
final List<ExpressionToken> outList = _list.toList();
|
||||
switch (state) {
|
||||
case ExpressionState.Start:
|
||||
newToken = new FloatToken('.');
|
||||
newToken = FloatToken('.');
|
||||
break;
|
||||
case ExpressionState.LeadingNeg:
|
||||
case ExpressionState.Number:
|
||||
final ExpressionToken last = outList.removeLast();
|
||||
newToken = new FloatToken(last.stringRep + '.');
|
||||
newToken = FloatToken(last.stringRep + '.');
|
||||
break;
|
||||
case ExpressionState.Point:
|
||||
case ExpressionState.NumberWithPoint:
|
||||
@@ -200,7 +200,7 @@ class CalcExpression {
|
||||
return null;
|
||||
}
|
||||
outList.add(newToken);
|
||||
return new CalcExpression(outList, ExpressionState.Point);
|
||||
return CalcExpression(outList, ExpressionState.Point);
|
||||
}
|
||||
|
||||
/// Append an operation symbol to the current expression and return a new
|
||||
@@ -219,8 +219,8 @@ class CalcExpression {
|
||||
break;
|
||||
}
|
||||
final List<ExpressionToken> outList = _list.toList();
|
||||
outList.add(new OperationToken(op));
|
||||
return new CalcExpression(outList, ExpressionState.Start);
|
||||
outList.add(OperationToken(op));
|
||||
return CalcExpression(outList, ExpressionState.Start);
|
||||
}
|
||||
|
||||
/// Append a leading minus sign to the current expression and return a new
|
||||
@@ -239,8 +239,8 @@ class CalcExpression {
|
||||
return null;
|
||||
}
|
||||
final List<ExpressionToken> outList = _list.toList();
|
||||
outList.add(new LeadingNegToken());
|
||||
return new CalcExpression(outList, ExpressionState.LeadingNeg);
|
||||
outList.add(LeadingNegToken());
|
||||
return CalcExpression(outList, ExpressionState.LeadingNeg);
|
||||
}
|
||||
|
||||
/// Append a minus sign to the current expression and return a new expression
|
||||
@@ -303,8 +303,8 @@ class CalcExpression {
|
||||
}
|
||||
}
|
||||
final List<ExpressionToken> outList = <ExpressionToken>[];
|
||||
outList.add(new ResultToken(currentTermValue));
|
||||
return new CalcExpression(outList, ExpressionState.Result);
|
||||
outList.add(ResultToken(currentTermValue));
|
||||
return CalcExpression(outList, ExpressionState.Result);
|
||||
}
|
||||
|
||||
/// Removes the next "term" from `list` and returns its numeric value.
|
||||
|
||||
@@ -18,25 +18,25 @@ class Palette {
|
||||
}
|
||||
|
||||
final List<Palette> allPalettes = <Palette>[
|
||||
new Palette(name: 'RED', primary: Colors.red, accent: Colors.redAccent, threshold: 300),
|
||||
new Palette(name: 'PINK', primary: Colors.pink, accent: Colors.pinkAccent, threshold: 200),
|
||||
new Palette(name: 'PURPLE', primary: Colors.purple, accent: Colors.purpleAccent, threshold: 200),
|
||||
new Palette(name: 'DEEP PURPLE', primary: Colors.deepPurple, accent: Colors.deepPurpleAccent, threshold: 200),
|
||||
new Palette(name: 'INDIGO', primary: Colors.indigo, accent: Colors.indigoAccent, threshold: 200),
|
||||
new Palette(name: 'BLUE', primary: Colors.blue, accent: Colors.blueAccent, threshold: 400),
|
||||
new Palette(name: 'LIGHT BLUE', primary: Colors.lightBlue, accent: Colors.lightBlueAccent, threshold: 500),
|
||||
new Palette(name: 'CYAN', primary: Colors.cyan, accent: Colors.cyanAccent, threshold: 600),
|
||||
new Palette(name: 'TEAL', primary: Colors.teal, accent: Colors.tealAccent, threshold: 400),
|
||||
new Palette(name: 'GREEN', primary: Colors.green, accent: Colors.greenAccent, threshold: 500),
|
||||
new Palette(name: 'LIGHT GREEN', primary: Colors.lightGreen, accent: Colors.lightGreenAccent, threshold: 600),
|
||||
new Palette(name: 'LIME', primary: Colors.lime, accent: Colors.limeAccent, threshold: 800),
|
||||
new Palette(name: 'YELLOW', primary: Colors.yellow, accent: Colors.yellowAccent),
|
||||
new Palette(name: 'AMBER', primary: Colors.amber, accent: Colors.amberAccent),
|
||||
new Palette(name: 'ORANGE', primary: Colors.orange, accent: Colors.orangeAccent, threshold: 700),
|
||||
new Palette(name: 'DEEP ORANGE', primary: Colors.deepOrange, accent: Colors.deepOrangeAccent, threshold: 400),
|
||||
new Palette(name: 'BROWN', primary: Colors.brown, threshold: 200),
|
||||
new Palette(name: 'GREY', primary: Colors.grey, threshold: 500),
|
||||
new Palette(name: 'BLUE GREY', primary: Colors.blueGrey, threshold: 500),
|
||||
Palette(name: 'RED', primary: Colors.red, accent: Colors.redAccent, threshold: 300),
|
||||
Palette(name: 'PINK', primary: Colors.pink, accent: Colors.pinkAccent, threshold: 200),
|
||||
Palette(name: 'PURPLE', primary: Colors.purple, accent: Colors.purpleAccent, threshold: 200),
|
||||
Palette(name: 'DEEP PURPLE', primary: Colors.deepPurple, accent: Colors.deepPurpleAccent, threshold: 200),
|
||||
Palette(name: 'INDIGO', primary: Colors.indigo, accent: Colors.indigoAccent, threshold: 200),
|
||||
Palette(name: 'BLUE', primary: Colors.blue, accent: Colors.blueAccent, threshold: 400),
|
||||
Palette(name: 'LIGHT BLUE', primary: Colors.lightBlue, accent: Colors.lightBlueAccent, threshold: 500),
|
||||
Palette(name: 'CYAN', primary: Colors.cyan, accent: Colors.cyanAccent, threshold: 600),
|
||||
Palette(name: 'TEAL', primary: Colors.teal, accent: Colors.tealAccent, threshold: 400),
|
||||
Palette(name: 'GREEN', primary: Colors.green, accent: Colors.greenAccent, threshold: 500),
|
||||
Palette(name: 'LIGHT GREEN', primary: Colors.lightGreen, accent: Colors.lightGreenAccent, threshold: 600),
|
||||
Palette(name: 'LIME', primary: Colors.lime, accent: Colors.limeAccent, threshold: 800),
|
||||
Palette(name: 'YELLOW', primary: Colors.yellow, accent: Colors.yellowAccent),
|
||||
Palette(name: 'AMBER', primary: Colors.amber, accent: Colors.amberAccent),
|
||||
Palette(name: 'ORANGE', primary: Colors.orange, accent: Colors.orangeAccent, threshold: 700),
|
||||
Palette(name: 'DEEP ORANGE', primary: Colors.deepOrange, accent: Colors.deepOrangeAccent, threshold: 400),
|
||||
Palette(name: 'BROWN', primary: Colors.brown, threshold: 200),
|
||||
Palette(name: 'GREY', primary: Colors.grey, threshold: 500),
|
||||
Palette(name: 'BLUE GREY', primary: Colors.blueGrey, threshold: 500),
|
||||
];
|
||||
|
||||
|
||||
@@ -59,21 +59,21 @@ class ColorItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Semantics(
|
||||
return Semantics(
|
||||
container: true,
|
||||
child: new Container(
|
||||
child: Container(
|
||||
height: kColorItemHeight,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
color: color,
|
||||
child: new SafeArea(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
new Text('$prefix$index'),
|
||||
new Text(colorString()),
|
||||
Text('$prefix$index'),
|
||||
Text(colorString()),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -100,22 +100,22 @@ class PaletteTabView extends StatelessWidget {
|
||||
final TextStyle whiteTextStyle = textTheme.body1.copyWith(color: Colors.white);
|
||||
final TextStyle blackTextStyle = textTheme.body1.copyWith(color: Colors.black);
|
||||
final List<Widget> colorItems = primaryKeys.map((int index) {
|
||||
return new DefaultTextStyle(
|
||||
return DefaultTextStyle(
|
||||
style: index > colors.threshold ? whiteTextStyle : blackTextStyle,
|
||||
child: new ColorItem(index: index, color: colors.primary[index]),
|
||||
child: ColorItem(index: index, color: colors.primary[index]),
|
||||
);
|
||||
}).toList();
|
||||
|
||||
if (colors.accent != null) {
|
||||
colorItems.addAll(accentKeys.map((int index) {
|
||||
return new DefaultTextStyle(
|
||||
return DefaultTextStyle(
|
||||
style: index > colors.threshold ? whiteTextStyle : blackTextStyle,
|
||||
child: new ColorItem(index: index, color: colors.accent[index], prefix: 'A'),
|
||||
child: ColorItem(index: index, color: colors.accent[index], prefix: 'A'),
|
||||
);
|
||||
}).toList());
|
||||
}
|
||||
|
||||
return new ListView(
|
||||
return ListView(
|
||||
itemExtent: kColorItemHeight,
|
||||
children: colorItems,
|
||||
);
|
||||
@@ -127,20 +127,20 @@ class ColorsDemo extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new DefaultTabController(
|
||||
return DefaultTabController(
|
||||
length: allPalettes.length,
|
||||
child: new Scaffold(
|
||||
appBar: new AppBar(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
elevation: 0.0,
|
||||
title: const Text('Colors'),
|
||||
bottom: new TabBar(
|
||||
bottom: TabBar(
|
||||
isScrollable: true,
|
||||
tabs: allPalettes.map((Palette swatch) => new Tab(text: swatch.name)).toList(),
|
||||
tabs: allPalettes.map((Palette swatch) => Tab(text: swatch.name)).toList(),
|
||||
),
|
||||
),
|
||||
body: new TabBarView(
|
||||
body: TabBarView(
|
||||
children: allPalettes.map((Palette colors) {
|
||||
return new PaletteTabView(colors: colors);
|
||||
return PaletteTabView(colors: colors);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -14,25 +14,25 @@ class _ContactCategory extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData themeData = Theme.of(context);
|
||||
return new Container(
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border(bottom: new BorderSide(color: themeData.dividerColor))
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: themeData.dividerColor))
|
||||
),
|
||||
child: new DefaultTextStyle(
|
||||
child: DefaultTextStyle(
|
||||
style: Theme.of(context).textTheme.subhead,
|
||||
child: new SafeArea(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Row(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 24.0),
|
||||
width: 72.0,
|
||||
child: new Icon(icon, color: themeData.primaryColor)
|
||||
child: Icon(icon, color: themeData.primaryColor)
|
||||
),
|
||||
new Expanded(child: new Column(children: children))
|
||||
Expanded(child: Column(children: children))
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -54,31 +54,31 @@ class _ContactItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData themeData = Theme.of(context);
|
||||
final List<Widget> columnChildren = lines.sublist(0, lines.length - 1).map((String line) => new Text(line)).toList();
|
||||
columnChildren.add(new Text(lines.last, style: themeData.textTheme.caption));
|
||||
final List<Widget> columnChildren = lines.sublist(0, lines.length - 1).map((String line) => Text(line)).toList();
|
||||
columnChildren.add(Text(lines.last, style: themeData.textTheme.caption));
|
||||
|
||||
final List<Widget> rowChildren = <Widget>[
|
||||
new Expanded(
|
||||
child: new Column(
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: columnChildren
|
||||
)
|
||||
)
|
||||
];
|
||||
if (icon != null) {
|
||||
rowChildren.add(new SizedBox(
|
||||
rowChildren.add(SizedBox(
|
||||
width: 72.0,
|
||||
child: new IconButton(
|
||||
icon: new Icon(icon),
|
||||
child: IconButton(
|
||||
icon: Icon(icon),
|
||||
color: themeData.primaryColor,
|
||||
onPressed: onPressed
|
||||
)
|
||||
));
|
||||
}
|
||||
return new MergeSemantics(
|
||||
child: new Padding(
|
||||
return MergeSemantics(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: rowChildren
|
||||
)
|
||||
@@ -91,36 +91,36 @@ class ContactsDemo extends StatefulWidget {
|
||||
static const String routeName = '/contacts';
|
||||
|
||||
@override
|
||||
ContactsDemoState createState() => new ContactsDemoState();
|
||||
ContactsDemoState createState() => ContactsDemoState();
|
||||
}
|
||||
|
||||
enum AppBarBehavior { normal, pinned, floating, snapping }
|
||||
|
||||
class ContactsDemoState extends State<ContactsDemo> {
|
||||
static final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
static final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final double _appBarHeight = 256.0;
|
||||
|
||||
AppBarBehavior _appBarBehavior = AppBarBehavior.pinned;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Theme(
|
||||
data: new ThemeData(
|
||||
return Theme(
|
||||
data: ThemeData(
|
||||
brightness: Brightness.light,
|
||||
primarySwatch: Colors.indigo,
|
||||
platform: Theme.of(context).platform,
|
||||
),
|
||||
child: new Scaffold(
|
||||
child: Scaffold(
|
||||
key: _scaffoldKey,
|
||||
body: new CustomScrollView(
|
||||
body: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
new SliverAppBar(
|
||||
SliverAppBar(
|
||||
expandedHeight: _appBarHeight,
|
||||
pinned: _appBarBehavior == AppBarBehavior.pinned,
|
||||
floating: _appBarBehavior == AppBarBehavior.floating || _appBarBehavior == AppBarBehavior.snapping,
|
||||
snap: _appBarBehavior == AppBarBehavior.snapping,
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.create),
|
||||
tooltip: 'Edit',
|
||||
onPressed: () {
|
||||
@@ -129,7 +129,7 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
));
|
||||
},
|
||||
),
|
||||
new PopupMenuButton<AppBarBehavior>(
|
||||
PopupMenuButton<AppBarBehavior>(
|
||||
onSelected: (AppBarBehavior value) {
|
||||
setState(() {
|
||||
_appBarBehavior = value;
|
||||
@@ -155,12 +155,12 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
],
|
||||
),
|
||||
],
|
||||
flexibleSpace: new FlexibleSpaceBar(
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
title: const Text('Ali Connors'),
|
||||
background: new Stack(
|
||||
background: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: <Widget>[
|
||||
new Image.asset(
|
||||
Image.asset(
|
||||
'people/ali_landscape.png',
|
||||
package: 'flutter_gallery_assets',
|
||||
fit: BoxFit.cover,
|
||||
@@ -181,14 +181,14 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
),
|
||||
),
|
||||
),
|
||||
new SliverList(
|
||||
delegate: new SliverChildListDelegate(<Widget>[
|
||||
new AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
SliverList(
|
||||
delegate: SliverChildListDelegate(<Widget>[
|
||||
AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: SystemUiOverlayStyle.dark,
|
||||
child: new _ContactCategory(
|
||||
child: _ContactCategory(
|
||||
icon: Icons.call,
|
||||
children: <Widget>[
|
||||
new _ContactItem(
|
||||
_ContactItem(
|
||||
icon: Icons.message,
|
||||
tooltip: 'Send message',
|
||||
onPressed: () {
|
||||
@@ -201,7 +201,7 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
'Mobile',
|
||||
],
|
||||
),
|
||||
new _ContactItem(
|
||||
_ContactItem(
|
||||
icon: Icons.message,
|
||||
tooltip: 'Send message',
|
||||
onPressed: () {
|
||||
@@ -214,7 +214,7 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
'Work',
|
||||
],
|
||||
),
|
||||
new _ContactItem(
|
||||
_ContactItem(
|
||||
icon: Icons.message,
|
||||
tooltip: 'Send message',
|
||||
onPressed: () {
|
||||
@@ -230,10 +230,10 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
],
|
||||
),
|
||||
),
|
||||
new _ContactCategory(
|
||||
_ContactCategory(
|
||||
icon: Icons.contact_mail,
|
||||
children: <Widget>[
|
||||
new _ContactItem(
|
||||
_ContactItem(
|
||||
icon: Icons.email,
|
||||
tooltip: 'Send personal e-mail',
|
||||
onPressed: () {
|
||||
@@ -246,7 +246,7 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
'Personal',
|
||||
],
|
||||
),
|
||||
new _ContactItem(
|
||||
_ContactItem(
|
||||
icon: Icons.email,
|
||||
tooltip: 'Send work e-mail',
|
||||
onPressed: () {
|
||||
@@ -261,10 +261,10 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
),
|
||||
],
|
||||
),
|
||||
new _ContactCategory(
|
||||
_ContactCategory(
|
||||
icon: Icons.location_on,
|
||||
children: <Widget>[
|
||||
new _ContactItem(
|
||||
_ContactItem(
|
||||
icon: Icons.map,
|
||||
tooltip: 'Open map',
|
||||
onPressed: () {
|
||||
@@ -278,7 +278,7 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
'Home',
|
||||
],
|
||||
),
|
||||
new _ContactItem(
|
||||
_ContactItem(
|
||||
icon: Icons.map,
|
||||
tooltip: 'Open map',
|
||||
onPressed: () {
|
||||
@@ -292,7 +292,7 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
'Work',
|
||||
],
|
||||
),
|
||||
new _ContactItem(
|
||||
_ContactItem(
|
||||
icon: Icons.map,
|
||||
tooltip: 'Open map',
|
||||
onPressed: () {
|
||||
@@ -308,28 +308,28 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
),
|
||||
],
|
||||
),
|
||||
new _ContactCategory(
|
||||
_ContactCategory(
|
||||
icon: Icons.today,
|
||||
children: <Widget>[
|
||||
new _ContactItem(
|
||||
_ContactItem(
|
||||
lines: const <String>[
|
||||
'Birthday',
|
||||
'January 9th, 1989',
|
||||
],
|
||||
),
|
||||
new _ContactItem(
|
||||
_ContactItem(
|
||||
lines: const <String>[
|
||||
'Wedding anniversary',
|
||||
'June 21st, 2014',
|
||||
],
|
||||
),
|
||||
new _ContactItem(
|
||||
_ContactItem(
|
||||
lines: const <String>[
|
||||
'First day in office',
|
||||
'January 20th, 2015',
|
||||
],
|
||||
),
|
||||
new _ContactItem(
|
||||
_ContactItem(
|
||||
lines: const <String>[
|
||||
'Last day in office',
|
||||
'August 9th, 2018',
|
||||
|
||||
@@ -10,8 +10,8 @@ class CupertinoProgressIndicatorDemo extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Cupertino Activity Indicator'),
|
||||
),
|
||||
body: const Center(
|
||||
|
||||
@@ -9,11 +9,11 @@ class CupertinoAlertDemo extends StatefulWidget {
|
||||
static const String routeName = '/cupertino/alert';
|
||||
|
||||
@override
|
||||
_CupertinoAlertDemoState createState() => new _CupertinoAlertDemoState();
|
||||
_CupertinoAlertDemoState createState() => _CupertinoAlertDemoState();
|
||||
}
|
||||
|
||||
class _CupertinoAlertDemoState extends State<CupertinoAlertDemo> {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
void showDemoDialog<T>({BuildContext context, Widget child}) {
|
||||
showDialog<T>(
|
||||
@@ -24,8 +24,8 @@ class _CupertinoAlertDemoState extends State<CupertinoAlertDemo> {
|
||||
// The value passed to Navigator.pop() or null.
|
||||
if (value != null) {
|
||||
_scaffoldKey.currentState.showSnackBar(
|
||||
new SnackBar(
|
||||
content: new Text('You selected: $value'),
|
||||
SnackBar(
|
||||
content: Text('You selected: $value'),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -39,8 +39,8 @@ class _CupertinoAlertDemoState extends State<CupertinoAlertDemo> {
|
||||
).then<void>((T value) {
|
||||
if (value != null) {
|
||||
_scaffoldKey.currentState.showSnackBar(
|
||||
new SnackBar(
|
||||
content: new Text('You selected: $value'),
|
||||
SnackBar(
|
||||
content: Text('You selected: $value'),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -49,31 +49,31 @@ class _CupertinoAlertDemoState extends State<CupertinoAlertDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: new AppBar(
|
||||
appBar: AppBar(
|
||||
title: const Text('Cupertino Alerts'),
|
||||
),
|
||||
body: new ListView(
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0),
|
||||
children: <Widget>[
|
||||
new CupertinoButton(
|
||||
CupertinoButton(
|
||||
child: const Text('Alert'),
|
||||
color: CupertinoColors.activeBlue,
|
||||
onPressed: () {
|
||||
showDemoDialog<String>(
|
||||
context: context,
|
||||
child: new CupertinoAlertDialog(
|
||||
child: CupertinoAlertDialog(
|
||||
title: const Text('Discard draft?'),
|
||||
actions: <Widget>[
|
||||
new CupertinoDialogAction(
|
||||
CupertinoDialogAction(
|
||||
child: const Text('Discard'),
|
||||
isDestructiveAction: true,
|
||||
onPressed: () {
|
||||
Navigator.pop(context, 'Discard');
|
||||
},
|
||||
),
|
||||
new CupertinoDialogAction(
|
||||
CupertinoDialogAction(
|
||||
child: const Text('Cancel'),
|
||||
isDefaultAction: true,
|
||||
onPressed: () {
|
||||
@@ -86,25 +86,25 @@ class _CupertinoAlertDemoState extends State<CupertinoAlertDemo> {
|
||||
},
|
||||
),
|
||||
const Padding(padding: EdgeInsets.all(8.0)),
|
||||
new CupertinoButton(
|
||||
CupertinoButton(
|
||||
child: const Text('Alert with Title'),
|
||||
color: CupertinoColors.activeBlue,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0),
|
||||
onPressed: () {
|
||||
showDemoDialog<String>(
|
||||
context: context,
|
||||
child: new CupertinoAlertDialog(
|
||||
child: CupertinoAlertDialog(
|
||||
title: const Text('Allow "Maps" to access your location while you are using the app?'),
|
||||
content: const Text('Your current location will be displayed on the map and used '
|
||||
'for directions, nearby search results, and estimated travel times.'),
|
||||
actions: <Widget>[
|
||||
new CupertinoDialogAction(
|
||||
CupertinoDialogAction(
|
||||
child: const Text('Don\'t Allow'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, 'Disallow');
|
||||
},
|
||||
),
|
||||
new CupertinoDialogAction(
|
||||
CupertinoDialogAction(
|
||||
child: const Text('Allow'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, 'Allow');
|
||||
@@ -116,7 +116,7 @@ class _CupertinoAlertDemoState extends State<CupertinoAlertDemo> {
|
||||
},
|
||||
),
|
||||
const Padding(padding: EdgeInsets.all(8.0)),
|
||||
new CupertinoButton(
|
||||
CupertinoButton(
|
||||
child: const Text('Alert with Buttons'),
|
||||
color: CupertinoColors.activeBlue,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0),
|
||||
@@ -133,7 +133,7 @@ class _CupertinoAlertDemoState extends State<CupertinoAlertDemo> {
|
||||
},
|
||||
),
|
||||
const Padding(padding: EdgeInsets.all(8.0)),
|
||||
new CupertinoButton(
|
||||
CupertinoButton(
|
||||
child: const Text('Alert Buttons Only'),
|
||||
color: CupertinoColors.activeBlue,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0),
|
||||
@@ -145,37 +145,37 @@ class _CupertinoAlertDemoState extends State<CupertinoAlertDemo> {
|
||||
},
|
||||
),
|
||||
const Padding(padding: EdgeInsets.all(8.0)),
|
||||
new CupertinoButton(
|
||||
CupertinoButton(
|
||||
child: const Text('Action Sheet'),
|
||||
color: CupertinoColors.activeBlue,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0),
|
||||
onPressed: () {
|
||||
showDemoActionSheet<String>(
|
||||
context: context,
|
||||
child: new CupertinoActionSheet(
|
||||
child: CupertinoActionSheet(
|
||||
title: const Text('Favorite Dessert'),
|
||||
message: const Text('Please select the best dessert from the options below.'),
|
||||
actions: <Widget>[
|
||||
new CupertinoActionSheetAction(
|
||||
CupertinoActionSheetAction(
|
||||
child: const Text('Profiteroles'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, 'Profiteroles');
|
||||
},
|
||||
),
|
||||
new CupertinoActionSheetAction(
|
||||
CupertinoActionSheetAction(
|
||||
child: const Text('Cannolis'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, 'Cannolis');
|
||||
},
|
||||
),
|
||||
new CupertinoActionSheetAction(
|
||||
CupertinoActionSheetAction(
|
||||
child: const Text('Trifle'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, 'Trifle');
|
||||
},
|
||||
),
|
||||
],
|
||||
cancelButton: new CupertinoActionSheetAction(
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
child: const Text('Cancel'),
|
||||
isDefaultAction: true,
|
||||
onPressed: () {
|
||||
@@ -200,53 +200,53 @@ class CupertinoDessertDialog extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new CupertinoAlertDialog(
|
||||
return CupertinoAlertDialog(
|
||||
title: title,
|
||||
content: content,
|
||||
actions: <Widget>[
|
||||
new CupertinoDialogAction(
|
||||
CupertinoDialogAction(
|
||||
child: const Text('Cheesecake'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, 'Cheesecake');
|
||||
},
|
||||
),
|
||||
new CupertinoDialogAction(
|
||||
CupertinoDialogAction(
|
||||
child: const Text('Tiramisu'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, 'Tiramisu');
|
||||
},
|
||||
),
|
||||
new CupertinoDialogAction(
|
||||
CupertinoDialogAction(
|
||||
child: const Text('Apple Pie'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, 'Apple Pie');
|
||||
},
|
||||
),
|
||||
new CupertinoDialogAction(
|
||||
CupertinoDialogAction(
|
||||
child: const Text("Devil's food cake"),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, "Devil's food cake");
|
||||
},
|
||||
),
|
||||
new CupertinoDialogAction(
|
||||
CupertinoDialogAction(
|
||||
child: const Text('Banana Split'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, 'Banana Split');
|
||||
},
|
||||
),
|
||||
new CupertinoDialogAction(
|
||||
CupertinoDialogAction(
|
||||
child: const Text('Oatmeal Cookie'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, 'Oatmeal Cookies');
|
||||
},
|
||||
),
|
||||
new CupertinoDialogAction(
|
||||
CupertinoDialogAction(
|
||||
child: const Text('Chocolate Brownie'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, 'Chocolate Brownies');
|
||||
},
|
||||
),
|
||||
new CupertinoDialogAction(
|
||||
CupertinoDialogAction(
|
||||
child: const Text('Cancel'),
|
||||
isDestructiveAction: true,
|
||||
onPressed: () {
|
||||
|
||||
@@ -9,7 +9,7 @@ class CupertinoButtonsDemo extends StatefulWidget {
|
||||
static const String routeName = '/cupertino/buttons';
|
||||
|
||||
@override
|
||||
_CupertinoButtonDemoState createState() => new _CupertinoButtonDemoState();
|
||||
_CupertinoButtonDemoState createState() => _CupertinoButtonDemoState();
|
||||
}
|
||||
|
||||
class _CupertinoButtonDemoState extends State<CupertinoButtonsDemo> {
|
||||
@@ -17,11 +17,11 @@ class _CupertinoButtonDemoState extends State<CupertinoButtonsDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Cupertino Buttons'),
|
||||
),
|
||||
body: new Column(
|
||||
body: Column(
|
||||
children: <Widget> [
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
@@ -30,20 +30,20 @@ class _CupertinoButtonDemoState extends State<CupertinoButtonsDemo> {
|
||||
'only when necessary.'
|
||||
),
|
||||
),
|
||||
new Expanded(
|
||||
child: new Column(
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget> [
|
||||
new Text(_pressedCount > 0
|
||||
Text(_pressedCount > 0
|
||||
? 'Button pressed $_pressedCount time${_pressedCount == 1 ? "" : "s"}'
|
||||
: ' '),
|
||||
const Padding(padding: EdgeInsets.all(12.0)),
|
||||
new Align(
|
||||
Align(
|
||||
alignment: const Alignment(0.0, -0.2),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new CupertinoButton(
|
||||
CupertinoButton(
|
||||
child: const Text('Cupertino Button'),
|
||||
onPressed: () {
|
||||
setState(() { _pressedCount += 1; });
|
||||
@@ -57,7 +57,7 @@ class _CupertinoButtonDemoState extends State<CupertinoButtonsDemo> {
|
||||
),
|
||||
),
|
||||
const Padding(padding: EdgeInsets.all(12.0)),
|
||||
new CupertinoButton(
|
||||
CupertinoButton(
|
||||
child: const Text('With Background'),
|
||||
color: CupertinoColors.activeBlue,
|
||||
onPressed: () {
|
||||
|
||||
@@ -30,11 +30,11 @@ const List<String> coolColorNames = <String>[
|
||||
|
||||
class CupertinoNavigationDemo extends StatelessWidget {
|
||||
CupertinoNavigationDemo()
|
||||
: colorItems = new List<Color>.generate(50, (int index) {
|
||||
return coolColors[new math.Random().nextInt(coolColors.length)];
|
||||
: colorItems = List<Color>.generate(50, (int index) {
|
||||
return coolColors[math.Random().nextInt(coolColors.length)];
|
||||
}) ,
|
||||
colorNameItems = new List<String>.generate(50, (int index) {
|
||||
return coolColorNames[new math.Random().nextInt(coolColorNames.length)];
|
||||
colorNameItems = List<String>.generate(50, (int index) {
|
||||
return coolColorNames[math.Random().nextInt(coolColorNames.length)];
|
||||
});
|
||||
|
||||
static const String routeName = '/cupertino/navigation';
|
||||
@@ -44,17 +44,17 @@ class CupertinoNavigationDemo extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new WillPopScope(
|
||||
return WillPopScope(
|
||||
// Prevent swipe popping of this page. Use explicit exit buttons only.
|
||||
onWillPop: () => new Future<bool>.value(true),
|
||||
child: new DefaultTextStyle(
|
||||
onWillPop: () => Future<bool>.value(true),
|
||||
child: DefaultTextStyle(
|
||||
style: const TextStyle(
|
||||
fontFamily: '.SF UI Text',
|
||||
fontSize: 17.0,
|
||||
color: CupertinoColors.black,
|
||||
),
|
||||
child: new CupertinoTabScaffold(
|
||||
tabBar: new CupertinoTabBar(
|
||||
child: CupertinoTabScaffold(
|
||||
tabBar: CupertinoTabBar(
|
||||
items: const <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.home),
|
||||
@@ -74,9 +74,9 @@ class CupertinoNavigationDemo extends StatelessWidget {
|
||||
assert(index >= 0 && index <= 2);
|
||||
switch (index) {
|
||||
case 0:
|
||||
return new CupertinoTabView(
|
||||
return CupertinoTabView(
|
||||
builder: (BuildContext context) {
|
||||
return new CupertinoDemoTab1(
|
||||
return CupertinoDemoTab1(
|
||||
colorItems: colorItems,
|
||||
colorNameItems: colorNameItems
|
||||
);
|
||||
@@ -85,13 +85,13 @@ class CupertinoNavigationDemo extends StatelessWidget {
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
return new CupertinoTabView(
|
||||
return CupertinoTabView(
|
||||
builder: (BuildContext context) => CupertinoDemoTab2(),
|
||||
defaultTitle: 'Support Chat',
|
||||
);
|
||||
break;
|
||||
case 2:
|
||||
return new CupertinoTabView(
|
||||
return CupertinoTabView(
|
||||
builder: (BuildContext context) => CupertinoDemoTab3(),
|
||||
defaultTitle: 'Account',
|
||||
);
|
||||
@@ -110,7 +110,7 @@ class ExitButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new CupertinoButton(
|
||||
return CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
child: const Tooltip(
|
||||
message: 'Back',
|
||||
@@ -133,13 +133,13 @@ class CupertinoDemoTab1 extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new CupertinoPageScaffold(
|
||||
child: new CustomScrollView(
|
||||
return CupertinoPageScaffold(
|
||||
child: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
const CupertinoSliverNavigationBar(
|
||||
trailing: ExitButton(),
|
||||
),
|
||||
new SliverPadding(
|
||||
SliverPadding(
|
||||
// Top media padding consumed by CupertinoSliverNavigationBar.
|
||||
// Left/Right media padding consumed by Tab1RowItem.
|
||||
padding: MediaQuery.of(context).removePadding(
|
||||
@@ -147,10 +147,10 @@ class CupertinoDemoTab1 extends StatelessWidget {
|
||||
removeLeft: true,
|
||||
removeRight: true,
|
||||
).padding,
|
||||
sliver: new SliverList(
|
||||
delegate: new SliverChildBuilderDelegate(
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
return new Tab1RowItem(
|
||||
return Tab1RowItem(
|
||||
index: index,
|
||||
lastItem: index == 49,
|
||||
color: colorItems[index],
|
||||
@@ -177,40 +177,40 @@ class Tab1RowItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Widget row = new GestureDetector(
|
||||
final Widget row = GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
Navigator.of(context).push(new CupertinoPageRoute<void>(
|
||||
Navigator.of(context).push(CupertinoPageRoute<void>(
|
||||
title: colorName,
|
||||
builder: (BuildContext context) => new Tab1ItemPage(
|
||||
builder: (BuildContext context) => Tab1ItemPage(
|
||||
color: color,
|
||||
colorName: colorName,
|
||||
index: index,
|
||||
),
|
||||
));
|
||||
},
|
||||
child: new SafeArea(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Padding(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 16.0, top: 8.0, bottom: 8.0, right: 8.0),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
height: 60.0,
|
||||
width: 60.0,
|
||||
decoration: new BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: new BorderRadius.circular(8.0),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
new Expanded(
|
||||
child: new Padding(
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Text(colorName),
|
||||
Text(colorName),
|
||||
const Padding(padding: EdgeInsets.only(top: 8.0)),
|
||||
const Text(
|
||||
'Buy this cool color',
|
||||
@@ -224,7 +224,7 @@ class Tab1RowItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
new CupertinoButton(
|
||||
CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
child: const Icon(CupertinoIcons.plus_circled,
|
||||
color: CupertinoColors.activeBlue,
|
||||
@@ -232,7 +232,7 @@ class Tab1RowItem extends StatelessWidget {
|
||||
),
|
||||
onPressed: () { },
|
||||
),
|
||||
new CupertinoButton(
|
||||
CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
child: const Icon(CupertinoIcons.share,
|
||||
color: CupertinoColors.activeBlue,
|
||||
@@ -250,10 +250,10 @@ class Tab1RowItem extends StatelessWidget {
|
||||
return row;
|
||||
}
|
||||
|
||||
return new Column(
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
row,
|
||||
new Container(
|
||||
Container(
|
||||
height: 1.0,
|
||||
color: const Color(0xFFD9D9D9),
|
||||
),
|
||||
@@ -270,16 +270,16 @@ class Tab1ItemPage extends StatefulWidget {
|
||||
final int index;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => new Tab1ItemPageState();
|
||||
State<StatefulWidget> createState() => Tab1ItemPageState();
|
||||
}
|
||||
|
||||
class Tab1ItemPageState extends State<Tab1ItemPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
relatedColors = new List<Color>.generate(10, (int index) {
|
||||
final math.Random random = new math.Random();
|
||||
return new Color.fromARGB(
|
||||
relatedColors = List<Color>.generate(10, (int index) {
|
||||
final math.Random random = math.Random();
|
||||
return Color.fromARGB(
|
||||
255,
|
||||
(widget.color.red + random.nextInt(100) - 50).clamp(0, 255),
|
||||
(widget.color.green + random.nextInt(100) - 50).clamp(0, 255),
|
||||
@@ -292,41 +292,41 @@ class Tab1ItemPageState extends State<Tab1ItemPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new CupertinoPageScaffold(
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: const CupertinoNavigationBar(
|
||||
trailing: ExitButton(),
|
||||
),
|
||||
child: new SafeArea(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new ListView(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
const Padding(padding: EdgeInsets.only(top: 16.0)),
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
height: 128.0,
|
||||
width: 128.0,
|
||||
decoration: new BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
color: widget.color,
|
||||
borderRadius: new BorderRadius.circular(24.0),
|
||||
borderRadius: BorderRadius.circular(24.0),
|
||||
),
|
||||
),
|
||||
const Padding(padding: EdgeInsets.only(left: 18.0)),
|
||||
new Expanded(
|
||||
child: new Column(
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
Text(
|
||||
widget.colorName,
|
||||
style: const TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const Padding(padding: EdgeInsets.only(top: 6.0)),
|
||||
new Text(
|
||||
Text(
|
||||
'Item number ${widget.index}',
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF8E8E93),
|
||||
@@ -335,14 +335,14 @@ class Tab1ItemPageState extends State<Tab1ItemPage> {
|
||||
),
|
||||
),
|
||||
const Padding(padding: EdgeInsets.only(top: 20.0)),
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
new CupertinoButton(
|
||||
CupertinoButton(
|
||||
color: CupertinoColors.activeBlue,
|
||||
minSize: 30.0,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24.0),
|
||||
borderRadius: new BorderRadius.circular(32.0),
|
||||
borderRadius: BorderRadius.circular(32.0),
|
||||
child: const Text(
|
||||
'GET',
|
||||
style: TextStyle(
|
||||
@@ -353,11 +353,11 @@ class Tab1ItemPageState extends State<Tab1ItemPage> {
|
||||
),
|
||||
onPressed: () { },
|
||||
),
|
||||
new CupertinoButton(
|
||||
CupertinoButton(
|
||||
color: CupertinoColors.activeBlue,
|
||||
minSize: 30.0,
|
||||
padding: EdgeInsets.zero,
|
||||
borderRadius: new BorderRadius.circular(32.0),
|
||||
borderRadius: BorderRadius.circular(32.0),
|
||||
child: const Icon(CupertinoIcons.ellipsis, color: CupertinoColors.white),
|
||||
onPressed: () { },
|
||||
),
|
||||
@@ -381,22 +381,22 @@ class Tab1ItemPageState extends State<Tab1ItemPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
new SizedBox(
|
||||
SizedBox(
|
||||
height: 200.0,
|
||||
child: new ListView.builder(
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: 10,
|
||||
itemExtent: 160.0,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 16.0),
|
||||
child: new Container(
|
||||
decoration: new BoxDecoration(
|
||||
borderRadius: new BorderRadius.circular(8.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
color: relatedColors[index],
|
||||
),
|
||||
child: new Center(
|
||||
child: new CupertinoButton(
|
||||
child: Center(
|
||||
child: CupertinoButton(
|
||||
child: const Icon(
|
||||
CupertinoIcons.plus_circled,
|
||||
color: CupertinoColors.white,
|
||||
@@ -420,13 +420,13 @@ class Tab1ItemPageState extends State<Tab1ItemPage> {
|
||||
class CupertinoDemoTab2 extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new CupertinoPageScaffold(
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: const CupertinoNavigationBar(
|
||||
trailing: ExitButton(),
|
||||
),
|
||||
child: new ListView(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
new Tab2Header(),
|
||||
Tab2Header(),
|
||||
]..addAll(buildTab2Conversation()),
|
||||
),
|
||||
);
|
||||
@@ -436,23 +436,23 @@ class CupertinoDemoTab2 extends StatelessWidget {
|
||||
class Tab2Header extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: new SafeArea(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new ClipRRect(
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16.0)),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFFE5E5E5),
|
||||
),
|
||||
child: new Padding(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 12.0),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: const <Widget>[
|
||||
Text(
|
||||
@@ -477,13 +477,13 @@ class Tab2Header extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
new Container(
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFFF3F3F3),
|
||||
),
|
||||
child: new Padding(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 12.0),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
const Text(
|
||||
@@ -505,9 +505,9 @@ class Tab2Header extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const Padding(padding: EdgeInsets.only(top: 8.0)),
|
||||
new Row(
|
||||
Row(
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
width: 44.0,
|
||||
height: 44.0,
|
||||
decoration: const BoxDecoration(
|
||||
@@ -521,7 +521,7 @@ class Tab2Header extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const Padding(padding: EdgeInsets.only(left: 8.0)),
|
||||
new Container(
|
||||
Container(
|
||||
width: 44.0,
|
||||
height: 44.0,
|
||||
decoration: const BoxDecoration(
|
||||
@@ -567,8 +567,8 @@ class Tab2ConversationBubble extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Container(
|
||||
decoration: new BoxDecoration(
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(18.0)),
|
||||
color: color == Tab2ConversationBubbleColor.blue
|
||||
? CupertinoColors.activeBlue
|
||||
@@ -576,9 +576,9 @@ class Tab2ConversationBubble extends StatelessWidget {
|
||||
),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 10.0),
|
||||
child: new Text(
|
||||
child: Text(
|
||||
text,
|
||||
style: new TextStyle(
|
||||
style: TextStyle(
|
||||
color: color == Tab2ConversationBubbleColor.blue
|
||||
? CupertinoColors.white
|
||||
: CupertinoColors.black,
|
||||
@@ -599,15 +599,15 @@ class Tab2ConversationAvatar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Container(
|
||||
decoration: new BoxDecoration(
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
gradient: new LinearGradient(
|
||||
gradient: LinearGradient(
|
||||
begin: FractionalOffset.topCenter,
|
||||
end: FractionalOffset.bottomCenter,
|
||||
colors: <Color>[
|
||||
color,
|
||||
new Color.fromARGB(
|
||||
Color.fromARGB(
|
||||
color.alpha,
|
||||
(color.red - 60).clamp(0, 255),
|
||||
(color.green - 60).clamp(0, 255),
|
||||
@@ -618,7 +618,7 @@ class Tab2ConversationAvatar extends StatelessWidget {
|
||||
),
|
||||
margin: const EdgeInsets.only(left: 8.0, bottom: 8.0),
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: new Text(
|
||||
child: Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
color: CupertinoColors.white,
|
||||
@@ -644,15 +644,15 @@ class Tab2ConversationRow extends StatelessWidget {
|
||||
|
||||
final bool isSelf = avatar == null;
|
||||
children.add(
|
||||
new Tab2ConversationBubble(
|
||||
Tab2ConversationBubble(
|
||||
text: text,
|
||||
color: isSelf
|
||||
? Tab2ConversationBubbleColor.blue
|
||||
: Tab2ConversationBubbleColor.gray,
|
||||
),
|
||||
);
|
||||
return new SafeArea(
|
||||
child: new Row(
|
||||
return SafeArea(
|
||||
child: Row(
|
||||
mainAxisAlignment: isSelf ? MainAxisAlignment.end : MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: isSelf ? CrossAxisAlignment.center : CrossAxisAlignment.end,
|
||||
@@ -703,25 +703,25 @@ List<Widget> buildTab2Conversation() {
|
||||
class CupertinoDemoTab3 extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new CupertinoPageScaffold(
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: const CupertinoNavigationBar(
|
||||
trailing: ExitButton(),
|
||||
),
|
||||
child: new DecoratedBox(
|
||||
child: DecoratedBox(
|
||||
decoration: const BoxDecoration(color: Color(0xFFEFEFF4)),
|
||||
child: new ListView(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
const Padding(padding: EdgeInsets.only(top: 32.0)),
|
||||
new GestureDetector(
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.of(context, rootNavigator: true).push(
|
||||
new CupertinoPageRoute<bool>(
|
||||
CupertinoPageRoute<bool>(
|
||||
fullscreenDialog: true,
|
||||
builder: (BuildContext context) => new Tab3Dialog(),
|
||||
builder: (BuildContext context) => Tab3Dialog(),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: new Container(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: CupertinoColors.white,
|
||||
border: Border(
|
||||
@@ -730,12 +730,12 @@ class CupertinoDemoTab3 extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
height: 44.0,
|
||||
child: new Padding(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: new SafeArea(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Row(
|
||||
child: Row(
|
||||
children: const <Widget>[
|
||||
Text(
|
||||
'Sign in',
|
||||
@@ -757,9 +757,9 @@ class CupertinoDemoTab3 extends StatelessWidget {
|
||||
class Tab3Dialog extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new CupertinoPageScaffold(
|
||||
navigationBar: new CupertinoNavigationBar(
|
||||
leading: new CupertinoButton(
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
leading: CupertinoButton(
|
||||
child: const Text('Cancel'),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () {
|
||||
@@ -767,8 +767,8 @@ class Tab3Dialog extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
),
|
||||
child: new Center(
|
||||
child: new Column(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
const Icon(
|
||||
@@ -777,7 +777,7 @@ class Tab3Dialog extends StatelessWidget {
|
||||
color: Color(0xFF646464),
|
||||
),
|
||||
const Padding(padding: EdgeInsets.only(top: 18.0)),
|
||||
new CupertinoButton(
|
||||
CupertinoButton(
|
||||
color: CupertinoColors.activeBlue,
|
||||
child: const Text('Sign in'),
|
||||
onPressed: () {
|
||||
|
||||
@@ -13,16 +13,16 @@ class CupertinoPickerDemo extends StatefulWidget {
|
||||
static const String routeName = '/cupertino/picker';
|
||||
|
||||
@override
|
||||
_CupertinoPickerDemoState createState() => new _CupertinoPickerDemoState();
|
||||
_CupertinoPickerDemoState createState() => _CupertinoPickerDemoState();
|
||||
}
|
||||
|
||||
class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
|
||||
int _selectedColorIndex = 0;
|
||||
|
||||
Duration timer = new Duration();
|
||||
Duration timer = Duration();
|
||||
|
||||
Widget _buildMenu(List<Widget> children) {
|
||||
return new Container(
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: CupertinoColors.white,
|
||||
border: Border(
|
||||
@@ -31,18 +31,18 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
|
||||
),
|
||||
),
|
||||
height: 44.0,
|
||||
child: new Padding(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: new SafeArea(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new DefaultTextStyle(
|
||||
child: DefaultTextStyle(
|
||||
style: const TextStyle(
|
||||
letterSpacing: -0.24,
|
||||
fontSize: 17.0,
|
||||
color: CupertinoColors.black,
|
||||
),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: children,
|
||||
),
|
||||
@@ -54,8 +54,8 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
|
||||
|
||||
Widget _buildColorPicker() {
|
||||
final FixedExtentScrollController scrollController =
|
||||
new FixedExtentScrollController(initialItem: _selectedColorIndex);
|
||||
return new CupertinoPicker(
|
||||
FixedExtentScrollController(initialItem: _selectedColorIndex);
|
||||
return CupertinoPicker(
|
||||
scrollController: scrollController,
|
||||
itemExtent: _kPickerItemHeight,
|
||||
backgroundColor: CupertinoColors.white,
|
||||
@@ -64,27 +64,27 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
|
||||
_selectedColorIndex = index;
|
||||
});
|
||||
},
|
||||
children: new List<Widget>.generate(coolColorNames.length, (int index) {
|
||||
return new Center(child:
|
||||
new Text(coolColorNames[index]),
|
||||
children: List<Widget>.generate(coolColorNames.length, (int index) {
|
||||
return Center(child:
|
||||
Text(coolColorNames[index]),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBottomPicker(Widget picker) {
|
||||
return new Container(
|
||||
return Container(
|
||||
height: _kPickerSheetHeight,
|
||||
color: CupertinoColors.white,
|
||||
child: new DefaultTextStyle(
|
||||
child: DefaultTextStyle(
|
||||
style: const TextStyle(
|
||||
color: CupertinoColors.black,
|
||||
fontSize: 22.0,
|
||||
),
|
||||
child: new GestureDetector(
|
||||
child: GestureDetector(
|
||||
// Blocks taps from propagating to the modal sheet and popping.
|
||||
onTap: () {},
|
||||
child: new SafeArea(
|
||||
child: SafeArea(
|
||||
child: picker,
|
||||
),
|
||||
),
|
||||
@@ -93,13 +93,13 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
|
||||
}
|
||||
|
||||
Widget _buildCountdownTimerPicker(BuildContext context) {
|
||||
return new GestureDetector(
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return _buildBottomPicker(
|
||||
new CupertinoTimerPicker(
|
||||
CupertinoTimerPicker(
|
||||
initialTimerDuration: timer,
|
||||
onTimerDurationChanged: (Duration newTimer) {
|
||||
setState(() {
|
||||
@@ -114,7 +114,7 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
|
||||
child: _buildMenu(
|
||||
<Widget>[
|
||||
const Text('Countdown Timer'),
|
||||
new Text(
|
||||
Text(
|
||||
'${timer.inHours}:'
|
||||
'${(timer.inMinutes % 60).toString().padLeft(2,'0')}:'
|
||||
'${(timer.inSeconds % 60).toString().padLeft(2,'0')}',
|
||||
@@ -127,22 +127,22 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Cupertino Picker'),
|
||||
),
|
||||
body: new DefaultTextStyle(
|
||||
body: DefaultTextStyle(
|
||||
style: const TextStyle(
|
||||
fontFamily: '.SF UI Text',
|
||||
fontSize: 17.0,
|
||||
color: CupertinoColors.black,
|
||||
),
|
||||
child: new DecoratedBox(
|
||||
child: DecoratedBox(
|
||||
decoration: const BoxDecoration(color: Color(0xFFEFEFF4)),
|
||||
child: new ListView(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
const Padding(padding: EdgeInsets.only(top: 32.0)),
|
||||
new GestureDetector(
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
@@ -154,7 +154,7 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
|
||||
child: _buildMenu(
|
||||
<Widget>[
|
||||
const Text('Favorite Color'),
|
||||
new Text(
|
||||
Text(
|
||||
coolColorNames[_selectedColorIndex],
|
||||
style: const TextStyle(
|
||||
color: CupertinoColors.inactiveGray
|
||||
|
||||
@@ -10,7 +10,7 @@ class CupertinoRefreshControlDemo extends StatefulWidget {
|
||||
static const String routeName = '/cupertino/refresh';
|
||||
|
||||
@override
|
||||
_CupertinoRefreshControlDemoState createState() => new _CupertinoRefreshControlDemoState();
|
||||
_CupertinoRefreshControlDemoState createState() => _CupertinoRefreshControlDemoState();
|
||||
}
|
||||
|
||||
class _CupertinoRefreshControlDemoState extends State<CupertinoRefreshControlDemo> {
|
||||
@@ -23,8 +23,8 @@ class _CupertinoRefreshControlDemoState extends State<CupertinoRefreshControlDem
|
||||
}
|
||||
|
||||
void repopulateList() {
|
||||
final Random random = new Random();
|
||||
randomizedContacts = new List<List<String>>.generate(
|
||||
final Random random = Random();
|
||||
randomizedContacts = List<List<String>>.generate(
|
||||
100,
|
||||
(int index) {
|
||||
return contacts[random.nextInt(contacts.length)]
|
||||
@@ -36,25 +36,25 @@ class _CupertinoRefreshControlDemoState extends State<CupertinoRefreshControlDem
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new DefaultTextStyle(
|
||||
return DefaultTextStyle(
|
||||
style: const TextStyle(
|
||||
fontFamily: '.SF UI Text',
|
||||
inherit: false,
|
||||
fontSize: 17.0,
|
||||
color: CupertinoColors.black,
|
||||
),
|
||||
child: new CupertinoPageScaffold(
|
||||
child: new DecoratedBox(
|
||||
child: CupertinoPageScaffold(
|
||||
child: DecoratedBox(
|
||||
decoration: const BoxDecoration(color: Color(0xFFEFEFF4)),
|
||||
child: new CustomScrollView(
|
||||
child: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
const CupertinoSliverNavigationBar(
|
||||
largeTitle: Text('Cupertino Refresh'),
|
||||
previousPageTitle: 'Cupertino',
|
||||
),
|
||||
new CupertinoSliverRefreshControl(
|
||||
CupertinoSliverRefreshControl(
|
||||
onRefresh: () {
|
||||
return new Future<void>.delayed(const Duration(seconds: 2))
|
||||
return Future<void>.delayed(const Duration(seconds: 2))
|
||||
..then((_) {
|
||||
if (mounted) {
|
||||
setState(() => repopulateList());
|
||||
@@ -62,12 +62,12 @@ class _CupertinoRefreshControlDemoState extends State<CupertinoRefreshControlDem
|
||||
});
|
||||
},
|
||||
),
|
||||
new SliverSafeArea(
|
||||
SliverSafeArea(
|
||||
top: false, // Top safe area is consumed by the navigation bar.
|
||||
sliver: new SliverList(
|
||||
delegate: new SliverChildBuilderDelegate(
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
return new _ListItem(
|
||||
return _ListItem(
|
||||
name: randomizedContacts[index][0],
|
||||
place: randomizedContacts[index][1],
|
||||
date: randomizedContacts[index][2],
|
||||
@@ -148,13 +148,13 @@ class _ListItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Container(
|
||||
return Container(
|
||||
color: CupertinoColors.white,
|
||||
height: 60.0,
|
||||
padding: const EdgeInsets.only(top: 9.0),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
width: 38.0,
|
||||
child: called
|
||||
? const Align(
|
||||
@@ -167,22 +167,22 @@ class _ListItem extends StatelessWidget {
|
||||
)
|
||||
: null,
|
||||
),
|
||||
new Expanded(
|
||||
child: new Container(
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Color(0xFFBCBBC1), width: 0.0),
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.only(left: 1.0, bottom: 9.0, right: 10.0),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
child: new Column(
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
Text(
|
||||
name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -191,7 +191,7 @@ class _ListItem extends StatelessWidget {
|
||||
letterSpacing: -0.18,
|
||||
),
|
||||
),
|
||||
new Text(
|
||||
Text(
|
||||
place,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -204,7 +204,7 @@ class _ListItem extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
new Text(
|
||||
Text(
|
||||
date,
|
||||
style: const TextStyle(
|
||||
color: CupertinoColors.inactiveGray,
|
||||
|
||||
@@ -13,7 +13,7 @@ class CupertinoSegmentedControlDemo extends StatefulWidget {
|
||||
static const String routeName = 'cupertino/segmented_control';
|
||||
|
||||
@override
|
||||
_CupertinoSegmentedControlDemoState createState() => new _CupertinoSegmentedControlDemoState();
|
||||
_CupertinoSegmentedControlDemoState createState() => _CupertinoSegmentedControlDemoState();
|
||||
}
|
||||
|
||||
class _CupertinoSegmentedControlDemoState extends State<CupertinoSegmentedControlDemo> {
|
||||
@@ -48,18 +48,18 @@ class _CupertinoSegmentedControlDemoState extends State<CupertinoSegmentedContro
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Segmented Control'),
|
||||
),
|
||||
body: new Column(
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
),
|
||||
new SizedBox(
|
||||
SizedBox(
|
||||
width: 500.0,
|
||||
child: new CupertinoSegmentedControl<int>(
|
||||
child: CupertinoSegmentedControl<int>(
|
||||
children: children,
|
||||
onValueChanged: (int newValue) {
|
||||
setState(() {
|
||||
@@ -69,20 +69,20 @@ class _CupertinoSegmentedControlDemoState extends State<CupertinoSegmentedContro
|
||||
groupValue: sharedValue,
|
||||
),
|
||||
),
|
||||
new Expanded(
|
||||
child: new Padding(
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 32.0,
|
||||
horizontal: 16.0,
|
||||
),
|
||||
child: new Container(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 64.0,
|
||||
horizontal: 16.0,
|
||||
),
|
||||
decoration: new BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoColors.white,
|
||||
borderRadius: new BorderRadius.circular(3.0),
|
||||
borderRadius: BorderRadius.circular(3.0),
|
||||
boxShadow: const <BoxShadow>[
|
||||
BoxShadow(
|
||||
offset: Offset(0.0, 3.0),
|
||||
|
||||
@@ -9,7 +9,7 @@ class CupertinoSliderDemo extends StatefulWidget {
|
||||
static const String routeName = '/cupertino/slider';
|
||||
|
||||
@override
|
||||
_CupertinoSliderDemoState createState() => new _CupertinoSliderDemoState();
|
||||
_CupertinoSliderDemoState createState() => _CupertinoSliderDemoState();
|
||||
}
|
||||
|
||||
class _CupertinoSliderDemoState extends State<CupertinoSliderDemo> {
|
||||
@@ -18,18 +18,18 @@ class _CupertinoSliderDemoState extends State<CupertinoSliderDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Cupertino Sliders'),
|
||||
),
|
||||
body: new Center(
|
||||
child: new Column(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
new Column(
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget> [
|
||||
new CupertinoSlider(
|
||||
CupertinoSlider(
|
||||
value: _value,
|
||||
min: 0.0,
|
||||
max: 100.0,
|
||||
@@ -39,13 +39,13 @@ class _CupertinoSliderDemoState extends State<CupertinoSliderDemo> {
|
||||
});
|
||||
}
|
||||
),
|
||||
new Text('Cupertino Continuous: ${_value.toStringAsFixed(1)}'),
|
||||
Text('Cupertino Continuous: ${_value.toStringAsFixed(1)}'),
|
||||
]
|
||||
),
|
||||
new Column(
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget> [
|
||||
new CupertinoSlider(
|
||||
CupertinoSlider(
|
||||
value: _discreteValue,
|
||||
min: 0.0,
|
||||
max: 100.0,
|
||||
@@ -56,7 +56,7 @@ class _CupertinoSliderDemoState extends State<CupertinoSliderDemo> {
|
||||
});
|
||||
}
|
||||
),
|
||||
new Text('Cupertino Discrete: $_discreteValue'),
|
||||
Text('Cupertino Discrete: $_discreteValue'),
|
||||
]
|
||||
),
|
||||
],
|
||||
|
||||
@@ -9,7 +9,7 @@ class CupertinoSwitchDemo extends StatefulWidget {
|
||||
static const String routeName = '/cupertino/switch';
|
||||
|
||||
@override
|
||||
_CupertinoSwitchDemoState createState() => new _CupertinoSwitchDemoState();
|
||||
_CupertinoSwitchDemoState createState() => _CupertinoSwitchDemoState();
|
||||
}
|
||||
|
||||
class _CupertinoSwitchDemoState extends State<CupertinoSwitchDemo> {
|
||||
@@ -18,19 +18,19 @@ class _CupertinoSwitchDemoState extends State<CupertinoSwitchDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Cupertino Switch'),
|
||||
),
|
||||
body: new Center(
|
||||
child: new Column(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
new Semantics(
|
||||
Semantics(
|
||||
container: true,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new CupertinoSwitch(
|
||||
CupertinoSwitch(
|
||||
value: _switchValue,
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
@@ -44,9 +44,9 @@ class _CupertinoSwitchDemoState extends State<CupertinoSwitchDemo> {
|
||||
],
|
||||
),
|
||||
),
|
||||
new Semantics(
|
||||
Semantics(
|
||||
container: true,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: const <Widget>[
|
||||
CupertinoSwitch(
|
||||
value: true,
|
||||
@@ -58,9 +58,9 @@ class _CupertinoSwitchDemoState extends State<CupertinoSwitchDemo> {
|
||||
],
|
||||
),
|
||||
),
|
||||
new Semantics(
|
||||
Semantics(
|
||||
container: true,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: const <Widget>[
|
||||
CupertinoSwitch(
|
||||
value: false,
|
||||
|
||||
@@ -7,28 +7,28 @@ class ImagesDemo extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new TabbedComponentDemoScaffold(
|
||||
return TabbedComponentDemoScaffold(
|
||||
title: 'Animated images',
|
||||
demos: <ComponentDemoTabData>[
|
||||
new ComponentDemoTabData(
|
||||
ComponentDemoTabData(
|
||||
tabName: 'WEBP',
|
||||
description: '',
|
||||
exampleCodeTag: 'animated_image',
|
||||
demoWidget: new Semantics(
|
||||
demoWidget: Semantics(
|
||||
label: 'Example of animated WEBP',
|
||||
child: new Image.asset(
|
||||
child: Image.asset(
|
||||
'animated_images/animated_flutter_stickers.webp',
|
||||
package: 'flutter_gallery_assets',
|
||||
),
|
||||
),
|
||||
),
|
||||
new ComponentDemoTabData(
|
||||
ComponentDemoTabData(
|
||||
tabName: 'GIF',
|
||||
description: '',
|
||||
exampleCodeTag: 'animated_image',
|
||||
demoWidget: new Semantics(
|
||||
demoWidget: Semantics(
|
||||
label: 'Example of animated GIF',
|
||||
child:new Image.asset(
|
||||
child:Image.asset(
|
||||
'animated_images/animated_flutter_lgtm.gif',
|
||||
package: 'flutter_gallery_assets',
|
||||
),
|
||||
|
||||
@@ -102,31 +102,31 @@ class CategoryView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return new ListView(
|
||||
key: new PageStorageKey<Category>(category),
|
||||
return ListView(
|
||||
key: PageStorageKey<Category>(category),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 16.0,
|
||||
horizontal: 64.0,
|
||||
),
|
||||
children: category.assets.map<Widget>((String asset) {
|
||||
return new Column(
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
new Card(
|
||||
child: new Container(
|
||||
Card(
|
||||
child: Container(
|
||||
width: 144.0,
|
||||
alignment: Alignment.center,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new Image.asset(
|
||||
Image.asset(
|
||||
asset,
|
||||
package: 'flutter_gallery_assets',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
new Container(
|
||||
Container(
|
||||
padding: const EdgeInsets.only(bottom: 16.0),
|
||||
alignment: AlignmentDirectional.center,
|
||||
child: new Text(
|
||||
child: Text(
|
||||
asset,
|
||||
style: theme.textTheme.caption,
|
||||
),
|
||||
@@ -164,27 +164,27 @@ class BackdropPanel extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return new Material(
|
||||
return Material(
|
||||
elevation: 2.0,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(16.0),
|
||||
topRight: Radius.circular(16.0),
|
||||
),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
new GestureDetector(
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onVerticalDragUpdate: onVerticalDragUpdate,
|
||||
onVerticalDragEnd: onVerticalDragEnd,
|
||||
onTap: onTap,
|
||||
child: new Container(
|
||||
child: Container(
|
||||
height: 48.0,
|
||||
padding: const EdgeInsetsDirectional.only(start: 16.0),
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: new DefaultTextStyle(
|
||||
child: DefaultTextStyle(
|
||||
style: theme.textTheme.subhead,
|
||||
child: new Tooltip(
|
||||
child: Tooltip(
|
||||
message: 'Tap to dismiss',
|
||||
child: title,
|
||||
),
|
||||
@@ -192,7 +192,7 @@ class BackdropPanel extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const Divider(height: 1.0),
|
||||
new Expanded(child: child),
|
||||
Expanded(child: child),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -209,21 +209,21 @@ class BackdropTitle extends AnimatedWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Animation<double> animation = listenable;
|
||||
return new DefaultTextStyle(
|
||||
return DefaultTextStyle(
|
||||
style: Theme.of(context).primaryTextTheme.title,
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
child: new Stack(
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
new Opacity(
|
||||
opacity: new CurvedAnimation(
|
||||
parent: new ReverseAnimation(animation),
|
||||
Opacity(
|
||||
opacity: CurvedAnimation(
|
||||
parent: ReverseAnimation(animation),
|
||||
curve: const Interval(0.5, 1.0),
|
||||
).value,
|
||||
child: const Text('Select a Category'),
|
||||
),
|
||||
new Opacity(
|
||||
opacity: new CurvedAnimation(
|
||||
Opacity(
|
||||
opacity: CurvedAnimation(
|
||||
parent: animation,
|
||||
curve: const Interval(0.5, 1.0),
|
||||
).value,
|
||||
@@ -240,18 +240,18 @@ class BackdropDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/backdrop';
|
||||
|
||||
@override
|
||||
_BackdropDemoState createState() => new _BackdropDemoState();
|
||||
_BackdropDemoState createState() => _BackdropDemoState();
|
||||
}
|
||||
|
||||
class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderStateMixin {
|
||||
final GlobalKey _backdropKey = new GlobalKey(debugLabel: 'Backdrop');
|
||||
final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop');
|
||||
AnimationController _controller;
|
||||
Category _category = allCategories[0];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = new AnimationController(
|
||||
_controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
value: 1.0,
|
||||
vsync: this,
|
||||
@@ -318,8 +318,8 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
|
||||
final Size panelSize = constraints.biggest;
|
||||
final double panelTop = panelSize.height - panelTitleHeight;
|
||||
|
||||
final Animation<RelativeRect> panelAnimation = new RelativeRectTween(
|
||||
begin: new RelativeRect.fromLTRB(
|
||||
final Animation<RelativeRect> panelAnimation = RelativeRectTween(
|
||||
begin: RelativeRect.fromLTRB(
|
||||
0.0,
|
||||
panelTop - MediaQuery.of(context).padding.bottom,
|
||||
0.0,
|
||||
@@ -327,7 +327,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
|
||||
),
|
||||
end: const RelativeRect.fromLTRB(0.0, 0.0, 0.0, 0.0),
|
||||
).animate(
|
||||
new CurvedAnimation(
|
||||
CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: Curves.linear,
|
||||
),
|
||||
@@ -336,15 +336,15 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final List<Widget> backdropItems = allCategories.map<Widget>((Category category) {
|
||||
final bool selected = category == _category;
|
||||
return new Material(
|
||||
return Material(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(4.0)),
|
||||
),
|
||||
color: selected
|
||||
? Colors.white.withOpacity(0.25)
|
||||
: Colors.transparent,
|
||||
child: new ListTile(
|
||||
title: new Text(category.title),
|
||||
child: ListTile(
|
||||
title: Text(category.title),
|
||||
selected: selected,
|
||||
onTap: () {
|
||||
_changeCategory(category);
|
||||
@@ -353,31 +353,31 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
|
||||
);
|
||||
}).toList();
|
||||
|
||||
return new Container(
|
||||
return Container(
|
||||
key: _backdropKey,
|
||||
color: theme.primaryColor,
|
||||
child: new Stack(
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
new ListTileTheme(
|
||||
ListTileTheme(
|
||||
iconColor: theme.primaryIconTheme.color,
|
||||
textColor: theme.primaryTextTheme.title.color.withOpacity(0.6),
|
||||
selectedColor: theme.primaryTextTheme.title.color,
|
||||
child: new Padding(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: backdropItems,
|
||||
),
|
||||
),
|
||||
),
|
||||
new PositionedTransition(
|
||||
PositionedTransition(
|
||||
rect: panelAnimation,
|
||||
child: new BackdropPanel(
|
||||
child: BackdropPanel(
|
||||
onTap: _toggleBackdropPanelVisibility,
|
||||
onVerticalDragUpdate: _handleDragUpdate,
|
||||
onVerticalDragEnd: _handleDragEnd,
|
||||
title: new Text(_category.title),
|
||||
child: new CategoryView(category: _category),
|
||||
title: Text(_category.title),
|
||||
child: CategoryView(category: _category),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -387,23 +387,23 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
elevation: 0.0,
|
||||
title: new BackdropTitle(
|
||||
title: BackdropTitle(
|
||||
listenable: _controller.view,
|
||||
),
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
onPressed: _toggleBackdropPanelVisibility,
|
||||
icon: new AnimatedIcon(
|
||||
icon: AnimatedIcon(
|
||||
icon: AnimatedIcons.close_menu,
|
||||
progress: _controller.view,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: new LayoutBuilder(
|
||||
body: LayoutBuilder(
|
||||
builder: _buildStack,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@ class BottomAppBarDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/bottom_app_bar';
|
||||
|
||||
@override
|
||||
State createState() => new _BottomAppBarDemoState();
|
||||
State createState() => _BottomAppBarDemoState();
|
||||
}
|
||||
|
||||
// Flutter generally frowns upon abbrevation however this class uses two
|
||||
@@ -16,7 +16,7 @@ class BottomAppBarDemo extends StatefulWidget {
|
||||
// for bottom application bar.
|
||||
|
||||
class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
|
||||
static final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
static final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
// FAB shape
|
||||
|
||||
@@ -137,13 +137,13 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: new AppBar(
|
||||
appBar: AppBar(
|
||||
title: const Text('Bottom app bar'),
|
||||
elevation: 0.0,
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.sentiment_very_satisfied),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@@ -153,38 +153,38 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
|
||||
),
|
||||
],
|
||||
),
|
||||
body: new ListView(
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.only(bottom: 88.0),
|
||||
children: <Widget>[
|
||||
const _Heading('FAB Shape'),
|
||||
|
||||
new _RadioItem<Widget>(kCircularFab, _fabShape, _onFabShapeChanged),
|
||||
new _RadioItem<Widget>(kDiamondFab, _fabShape, _onFabShapeChanged),
|
||||
new _RadioItem<Widget>(kNoFab, _fabShape, _onFabShapeChanged),
|
||||
_RadioItem<Widget>(kCircularFab, _fabShape, _onFabShapeChanged),
|
||||
_RadioItem<Widget>(kDiamondFab, _fabShape, _onFabShapeChanged),
|
||||
_RadioItem<Widget>(kNoFab, _fabShape, _onFabShapeChanged),
|
||||
|
||||
const Divider(),
|
||||
const _Heading('Notch'),
|
||||
|
||||
new _RadioItem<bool>(kShowNotchTrue, _showNotch, _onShowNotchChanged),
|
||||
new _RadioItem<bool>(kShowNotchFalse, _showNotch, _onShowNotchChanged),
|
||||
_RadioItem<bool>(kShowNotchTrue, _showNotch, _onShowNotchChanged),
|
||||
_RadioItem<bool>(kShowNotchFalse, _showNotch, _onShowNotchChanged),
|
||||
|
||||
const Divider(),
|
||||
const _Heading('FAB Position'),
|
||||
|
||||
new _RadioItem<FloatingActionButtonLocation>(kFabEndDocked, _fabLocation, _onFabLocationChanged),
|
||||
new _RadioItem<FloatingActionButtonLocation>(kFabCenterDocked, _fabLocation, _onFabLocationChanged),
|
||||
new _RadioItem<FloatingActionButtonLocation>(kFabEndFloat, _fabLocation, _onFabLocationChanged),
|
||||
new _RadioItem<FloatingActionButtonLocation>(kFabCenterFloat, _fabLocation, _onFabLocationChanged),
|
||||
_RadioItem<FloatingActionButtonLocation>(kFabEndDocked, _fabLocation, _onFabLocationChanged),
|
||||
_RadioItem<FloatingActionButtonLocation>(kFabCenterDocked, _fabLocation, _onFabLocationChanged),
|
||||
_RadioItem<FloatingActionButtonLocation>(kFabEndFloat, _fabLocation, _onFabLocationChanged),
|
||||
_RadioItem<FloatingActionButtonLocation>(kFabCenterFloat, _fabLocation, _onFabLocationChanged),
|
||||
|
||||
const Divider(),
|
||||
const _Heading('App bar color'),
|
||||
|
||||
new _ColorsItem(kBabColors, _babColor, _onBabColorChanged),
|
||||
_ColorsItem(kBabColors, _babColor, _onBabColorChanged),
|
||||
],
|
||||
),
|
||||
floatingActionButton: _fabShape.value,
|
||||
floatingActionButtonLocation: _fabLocation.value,
|
||||
bottomNavigationBar: new _DemoBottomAppBar(
|
||||
bottomNavigationBar: _DemoBottomAppBar(
|
||||
color: _babColor,
|
||||
fabLocation: _fabLocation.value,
|
||||
shape: _selectNotch(),
|
||||
@@ -224,29 +224,29 @@ class _RadioItem<T> extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return new Container(
|
||||
return Container(
|
||||
height: 56.0,
|
||||
padding: const EdgeInsetsDirectional.only(start: 16.0),
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: new MergeSemantics(
|
||||
child: new Row(
|
||||
child: MergeSemantics(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Radio<_ChoiceValue<T>>(
|
||||
Radio<_ChoiceValue<T>>(
|
||||
value: value,
|
||||
groupValue: groupValue,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
new Expanded(
|
||||
child: new Semantics(
|
||||
Expanded(
|
||||
child: Semantics(
|
||||
container: true,
|
||||
button: true,
|
||||
label: value.label,
|
||||
child: new GestureDetector(
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
onChanged(value);
|
||||
},
|
||||
child: new Text(
|
||||
child: Text(
|
||||
value.title,
|
||||
style: theme.textTheme.subhead,
|
||||
),
|
||||
@@ -276,10 +276,10 @@ class _ColorsItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Row(
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: colors.map((_NamedColor namedColor) {
|
||||
return new RawMaterialButton(
|
||||
return RawMaterialButton(
|
||||
onPressed: () {
|
||||
onChanged(namedColor.color);
|
||||
},
|
||||
@@ -288,13 +288,13 @@ class _ColorsItem extends StatelessWidget {
|
||||
height: 32.0,
|
||||
),
|
||||
fillColor: namedColor.color,
|
||||
shape: new CircleBorder(
|
||||
side: new BorderSide(
|
||||
shape: CircleBorder(
|
||||
side: BorderSide(
|
||||
color: namedColor.color == selectedColor ? Colors.black : const Color(0xFFD5D7DA),
|
||||
width: 2.0,
|
||||
),
|
||||
),
|
||||
child: new Semantics(
|
||||
child: Semantics(
|
||||
value: namedColor.name,
|
||||
selected: namedColor.color == selectedColor,
|
||||
),
|
||||
@@ -312,11 +312,11 @@ class _Heading extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return new Container(
|
||||
return Container(
|
||||
height: 48.0,
|
||||
padding: const EdgeInsetsDirectional.only(start: 56.0),
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: new Text(
|
||||
child: Text(
|
||||
text,
|
||||
style: theme.textTheme.body1.copyWith(
|
||||
color: theme.primaryColor,
|
||||
@@ -345,7 +345,7 @@ class _DemoBottomAppBar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<Widget> rowContents = <Widget> [
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.menu),
|
||||
onPressed: () {
|
||||
showModalBottomSheet<Null>(
|
||||
@@ -363,7 +363,7 @@ class _DemoBottomAppBar extends StatelessWidget {
|
||||
}
|
||||
|
||||
rowContents.addAll(<Widget> [
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.search),
|
||||
onPressed: () {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
@@ -371,8 +371,8 @@ class _DemoBottomAppBar extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
new IconButton(
|
||||
icon: new Icon(
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Theme.of(context).platform == TargetPlatform.iOS
|
||||
? Icons.more_horiz
|
||||
: Icons.more_vert,
|
||||
@@ -385,9 +385,9 @@ class _DemoBottomAppBar extends StatelessWidget {
|
||||
),
|
||||
]);
|
||||
|
||||
return new BottomAppBar(
|
||||
return BottomAppBar(
|
||||
color: color,
|
||||
child: new Row(children: rowContents),
|
||||
child: Row(children: rowContents),
|
||||
shape: shape,
|
||||
);
|
||||
}
|
||||
@@ -399,8 +399,8 @@ class _DemoDrawer extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Drawer(
|
||||
child: new Column(
|
||||
return Drawer(
|
||||
child: Column(
|
||||
children: const <Widget>[
|
||||
ListTile(
|
||||
leading: Icon(Icons.search),
|
||||
@@ -428,16 +428,16 @@ class _DiamondFab extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Material(
|
||||
return Material(
|
||||
shape: const _DiamondBorder(),
|
||||
color: Colors.orange,
|
||||
child: new InkWell(
|
||||
child: InkWell(
|
||||
onTap: onPressed,
|
||||
child: new Container(
|
||||
child: Container(
|
||||
width: 56.0,
|
||||
height: 56.0,
|
||||
child: IconTheme.merge(
|
||||
data: new IconThemeData(color: Theme.of(context).accentIconTheme.color),
|
||||
data: IconThemeData(color: Theme.of(context).accentIconTheme.color),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
@@ -453,7 +453,7 @@ class _DiamondNotchedRectangle implements NotchedShape {
|
||||
@override
|
||||
Path getOuterPath(Rect host, Rect guest) {
|
||||
if (!host.overlaps(guest))
|
||||
return new Path()..addRect(host);
|
||||
return Path()..addRect(host);
|
||||
assert(guest.width > 0.0);
|
||||
|
||||
final Rect intersection = guest.intersect(host);
|
||||
@@ -473,7 +473,7 @@ class _DiamondNotchedRectangle implements NotchedShape {
|
||||
intersection.height * (guest.height / 2.0)
|
||||
/ (guest.width / 2.0);
|
||||
|
||||
return new Path()
|
||||
return Path()
|
||||
..moveTo(host.left, host.top)
|
||||
..lineTo(guest.center.dx - notchToCenter, host.top)
|
||||
..lineTo(guest.left + guest.width / 2.0, guest.bottom)
|
||||
@@ -500,7 +500,7 @@ class _DiamondBorder extends ShapeBorder {
|
||||
|
||||
@override
|
||||
Path getOuterPath(Rect rect, { TextDirection textDirection }) {
|
||||
return new Path()
|
||||
return Path()
|
||||
..moveTo(rect.left + rect.width / 2.0, rect.top)
|
||||
..lineTo(rect.right, rect.top + rect.height / 2.0)
|
||||
..lineTo(rect.left + rect.width / 2.0, rect.bottom)
|
||||
|
||||
@@ -14,17 +14,17 @@ class NavigationIconView {
|
||||
}) : _icon = icon,
|
||||
_color = color,
|
||||
_title = title,
|
||||
item = new BottomNavigationBarItem(
|
||||
item = BottomNavigationBarItem(
|
||||
icon: icon,
|
||||
activeIcon: activeIcon,
|
||||
title: new Text(title),
|
||||
title: Text(title),
|
||||
backgroundColor: color,
|
||||
),
|
||||
controller = new AnimationController(
|
||||
controller = AnimationController(
|
||||
duration: kThemeAnimationDuration,
|
||||
vsync: vsync,
|
||||
) {
|
||||
_animation = new CurvedAnimation(
|
||||
_animation = CurvedAnimation(
|
||||
parent: controller,
|
||||
curve: const Interval(0.5, 1.0, curve: Curves.fastOutSlowIn),
|
||||
);
|
||||
@@ -48,19 +48,19 @@ class NavigationIconView {
|
||||
: themeData.accentColor;
|
||||
}
|
||||
|
||||
return new FadeTransition(
|
||||
return FadeTransition(
|
||||
opacity: _animation,
|
||||
child: new SlideTransition(
|
||||
position: new Tween<Offset>(
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0.0, 0.02), // Slightly down.
|
||||
end: Offset.zero,
|
||||
).animate(_animation),
|
||||
child: new IconTheme(
|
||||
data: new IconThemeData(
|
||||
child: IconTheme(
|
||||
data: IconThemeData(
|
||||
color: iconColor,
|
||||
size: 120.0,
|
||||
),
|
||||
child: new Semantics(
|
||||
child: Semantics(
|
||||
label: 'Placeholder for $_title tab',
|
||||
child: _icon,
|
||||
),
|
||||
@@ -74,7 +74,7 @@ class CustomIcon extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final IconThemeData iconTheme = IconTheme.of(context);
|
||||
return new Container(
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(4.0),
|
||||
width: iconTheme.size - 8.0,
|
||||
height: iconTheme.size - 8.0,
|
||||
@@ -87,12 +87,12 @@ class CustomInactiveIcon extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final IconThemeData iconTheme = IconTheme.of(context);
|
||||
return new Container(
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(4.0),
|
||||
width: iconTheme.size - 8.0,
|
||||
height: iconTheme.size - 8.0,
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border.all(color: iconTheme.color, width: 2.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: iconTheme.color, width: 2.0),
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -102,7 +102,7 @@ class BottomNavigationDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/bottom_navigation';
|
||||
|
||||
@override
|
||||
_BottomNavigationDemoState createState() => new _BottomNavigationDemoState();
|
||||
_BottomNavigationDemoState createState() => _BottomNavigationDemoState();
|
||||
}
|
||||
|
||||
class _BottomNavigationDemoState extends State<BottomNavigationDemo>
|
||||
@@ -115,34 +115,34 @@ class _BottomNavigationDemoState extends State<BottomNavigationDemo>
|
||||
void initState() {
|
||||
super.initState();
|
||||
_navigationViews = <NavigationIconView>[
|
||||
new NavigationIconView(
|
||||
NavigationIconView(
|
||||
icon: const Icon(Icons.access_alarm),
|
||||
title: 'Alarm',
|
||||
color: Colors.deepPurple,
|
||||
vsync: this,
|
||||
),
|
||||
new NavigationIconView(
|
||||
activeIcon: new CustomIcon(),
|
||||
icon: new CustomInactiveIcon(),
|
||||
NavigationIconView(
|
||||
activeIcon: CustomIcon(),
|
||||
icon: CustomInactiveIcon(),
|
||||
title: 'Box',
|
||||
color: Colors.deepOrange,
|
||||
vsync: this,
|
||||
),
|
||||
new NavigationIconView(
|
||||
NavigationIconView(
|
||||
activeIcon: const Icon(Icons.cloud),
|
||||
icon: const Icon(Icons.cloud_queue),
|
||||
title: 'Cloud',
|
||||
color: Colors.teal,
|
||||
vsync: this,
|
||||
),
|
||||
new NavigationIconView(
|
||||
NavigationIconView(
|
||||
activeIcon: const Icon(Icons.favorite),
|
||||
icon: const Icon(Icons.favorite_border),
|
||||
title: 'Favorites',
|
||||
color: Colors.indigo,
|
||||
vsync: this,
|
||||
),
|
||||
new NavigationIconView(
|
||||
NavigationIconView(
|
||||
icon: const Icon(Icons.event_available),
|
||||
title: 'Event',
|
||||
color: Colors.pink,
|
||||
@@ -184,12 +184,12 @@ class _BottomNavigationDemoState extends State<BottomNavigationDemo>
|
||||
return aValue.compareTo(bValue);
|
||||
});
|
||||
|
||||
return new Stack(children: transitions);
|
||||
return Stack(children: transitions);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final BottomNavigationBar botNavBar = new BottomNavigationBar(
|
||||
final BottomNavigationBar botNavBar = BottomNavigationBar(
|
||||
items: _navigationViews
|
||||
.map((NavigationIconView navigationView) => navigationView.item)
|
||||
.toList(),
|
||||
@@ -204,11 +204,11 @@ class _BottomNavigationDemoState extends State<BottomNavigationDemo>
|
||||
},
|
||||
);
|
||||
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Bottom navigation'),
|
||||
actions: <Widget>[
|
||||
new PopupMenuButton<BottomNavigationBarType>(
|
||||
PopupMenuButton<BottomNavigationBarType>(
|
||||
onSelected: (BottomNavigationBarType value) {
|
||||
setState(() {
|
||||
_type = value;
|
||||
@@ -227,7 +227,7 @@ class _BottomNavigationDemoState extends State<BottomNavigationDemo>
|
||||
)
|
||||
],
|
||||
),
|
||||
body: new Center(
|
||||
body: Center(
|
||||
child: _buildTransitionsStack()
|
||||
),
|
||||
bottomNavigationBar: botNavBar,
|
||||
|
||||
@@ -49,7 +49,7 @@ class ButtonsDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/buttons';
|
||||
|
||||
@override
|
||||
_ButtonsDemoState createState() => new _ButtonsDemoState();
|
||||
_ButtonsDemoState createState() => _ButtonsDemoState();
|
||||
}
|
||||
|
||||
class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
@@ -62,46 +62,46 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
);
|
||||
|
||||
final List<ComponentDemoTabData> demos = <ComponentDemoTabData>[
|
||||
new ComponentDemoTabData(
|
||||
ComponentDemoTabData(
|
||||
tabName: 'RAISED',
|
||||
description: _raisedText,
|
||||
demoWidget: new ButtonTheme.fromButtonThemeData(
|
||||
demoWidget: ButtonTheme.fromButtonThemeData(
|
||||
data: buttonTheme,
|
||||
child: buildRaisedButton(),
|
||||
),
|
||||
exampleCodeTag: _raisedCode,
|
||||
),
|
||||
new ComponentDemoTabData(
|
||||
ComponentDemoTabData(
|
||||
tabName: 'FLAT',
|
||||
description: _flatText,
|
||||
demoWidget: new ButtonTheme.fromButtonThemeData(
|
||||
demoWidget: ButtonTheme.fromButtonThemeData(
|
||||
data: buttonTheme,
|
||||
child: buildFlatButton(),
|
||||
),
|
||||
exampleCodeTag: _flatCode,
|
||||
),
|
||||
new ComponentDemoTabData(
|
||||
ComponentDemoTabData(
|
||||
tabName: 'OUTLINE',
|
||||
description: _outlineText,
|
||||
demoWidget: new ButtonTheme.fromButtonThemeData(
|
||||
demoWidget: ButtonTheme.fromButtonThemeData(
|
||||
data: buttonTheme,
|
||||
child: buildOutlineButton(),
|
||||
),
|
||||
exampleCodeTag: _outlineCode,
|
||||
),
|
||||
new ComponentDemoTabData(
|
||||
ComponentDemoTabData(
|
||||
tabName: 'DROPDOWN',
|
||||
description: _dropdownText,
|
||||
demoWidget: buildDropdownButton(),
|
||||
exampleCodeTag: _dropdownCode,
|
||||
),
|
||||
new ComponentDemoTabData(
|
||||
ComponentDemoTabData(
|
||||
tabName: 'ICON',
|
||||
description: _iconText,
|
||||
demoWidget: buildIconButton(),
|
||||
exampleCodeTag: _iconCode,
|
||||
),
|
||||
new ComponentDemoTabData(
|
||||
ComponentDemoTabData(
|
||||
tabName: 'ACTION',
|
||||
description: _actionText,
|
||||
demoWidget: buildActionButton(),
|
||||
@@ -109,11 +109,11 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
),
|
||||
];
|
||||
|
||||
return new TabbedComponentDemoScaffold(
|
||||
return TabbedComponentDemoScaffold(
|
||||
title: 'Buttons',
|
||||
demos: demos,
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.sentiment_very_satisfied),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@@ -126,15 +126,15 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
}
|
||||
|
||||
Widget buildRaisedButton() {
|
||||
return new Align(
|
||||
return Align(
|
||||
alignment: const Alignment(0.0, -0.2),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new ButtonBar(
|
||||
ButtonBar(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new RaisedButton(
|
||||
RaisedButton(
|
||||
child: const Text('RAISED BUTTON'),
|
||||
onPressed: () {
|
||||
// Perform some action
|
||||
@@ -146,17 +146,17 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
),
|
||||
],
|
||||
),
|
||||
new ButtonBar(
|
||||
ButtonBar(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new RaisedButton.icon(
|
||||
RaisedButton.icon(
|
||||
icon: const Icon(Icons.add, size: 18.0),
|
||||
label: const Text('RAISED BUTTON'),
|
||||
onPressed: () {
|
||||
// Perform some action
|
||||
},
|
||||
),
|
||||
new RaisedButton.icon(
|
||||
RaisedButton.icon(
|
||||
icon: const Icon(Icons.add, size: 18.0),
|
||||
label: const Text('DISABLED'),
|
||||
onPressed: null,
|
||||
@@ -169,15 +169,15 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
}
|
||||
|
||||
Widget buildFlatButton() {
|
||||
return new Align(
|
||||
return Align(
|
||||
alignment: const Alignment(0.0, -0.2),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new ButtonBar(
|
||||
ButtonBar(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('FLAT BUTTON'),
|
||||
onPressed: () {
|
||||
// Perform some action
|
||||
@@ -189,17 +189,17 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
),
|
||||
],
|
||||
),
|
||||
new ButtonBar(
|
||||
ButtonBar(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new FlatButton.icon(
|
||||
FlatButton.icon(
|
||||
icon: const Icon(Icons.add_circle_outline, size: 18.0),
|
||||
label: const Text('FLAT BUTTON'),
|
||||
onPressed: () {
|
||||
// Perform some action
|
||||
},
|
||||
),
|
||||
new FlatButton.icon(
|
||||
FlatButton.icon(
|
||||
icon: const Icon(Icons.add_circle_outline, size: 18.0),
|
||||
label: const Text('DISABLED'),
|
||||
onPressed: null,
|
||||
@@ -212,15 +212,15 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
}
|
||||
|
||||
Widget buildOutlineButton() {
|
||||
return new Align(
|
||||
return Align(
|
||||
alignment: const Alignment(0.0, -0.2),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new ButtonBar(
|
||||
ButtonBar(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new OutlineButton(
|
||||
OutlineButton(
|
||||
child: const Text('OUTLINE BUTTON'),
|
||||
onPressed: () {
|
||||
// Perform some action
|
||||
@@ -232,17 +232,17 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
),
|
||||
],
|
||||
),
|
||||
new ButtonBar(
|
||||
ButtonBar(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new OutlineButton.icon(
|
||||
OutlineButton.icon(
|
||||
icon: const Icon(Icons.add, size: 18.0),
|
||||
label: const Text('OUTLINE BUTTON'),
|
||||
onPressed: () {
|
||||
// Perform some action
|
||||
},
|
||||
),
|
||||
new OutlineButton.icon(
|
||||
OutlineButton.icon(
|
||||
icon: const Icon(Icons.add, size: 18.0),
|
||||
label: const Text('DISABLED'),
|
||||
onPressed: null,
|
||||
@@ -260,14 +260,14 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
String dropdown3Value = 'Four';
|
||||
|
||||
Widget buildDropdownButton() {
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new ListTile(
|
||||
ListTile(
|
||||
title: const Text('Simple dropdown:'),
|
||||
trailing: new DropdownButton<String>(
|
||||
trailing: DropdownButton<String>(
|
||||
value: dropdown1Value,
|
||||
onChanged: (String newValue) {
|
||||
setState(() {
|
||||
@@ -275,9 +275,9 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
});
|
||||
},
|
||||
items: <String>['One', 'Two', 'Free', 'Four'].map((String value) {
|
||||
return new DropdownMenuItem<String>(
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: new Text(value),
|
||||
child: Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
@@ -285,9 +285,9 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
const SizedBox(
|
||||
height: 24.0,
|
||||
),
|
||||
new ListTile(
|
||||
ListTile(
|
||||
title: const Text('Dropdown with a hint:'),
|
||||
trailing: new DropdownButton<String>(
|
||||
trailing: DropdownButton<String>(
|
||||
value: dropdown2Value,
|
||||
hint: const Text('Choose'),
|
||||
onChanged: (String newValue) {
|
||||
@@ -296,9 +296,9 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
});
|
||||
},
|
||||
items: <String>['One', 'Two', 'Free', 'Four'].map((String value) {
|
||||
return new DropdownMenuItem<String>(
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: new Text(value),
|
||||
child: Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
@@ -306,9 +306,9 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
const SizedBox(
|
||||
height: 24.0,
|
||||
),
|
||||
new ListTile(
|
||||
ListTile(
|
||||
title: const Text('Scrollable dropdown:'),
|
||||
trailing: new DropdownButton<String>(
|
||||
trailing: DropdownButton<String>(
|
||||
value: dropdown3Value,
|
||||
onChanged: (String newValue) {
|
||||
setState(() {
|
||||
@@ -320,9 +320,9 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
'Bit', 'More', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten'
|
||||
]
|
||||
.map((String value) {
|
||||
return new DropdownMenuItem<String>(
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: new Text(value),
|
||||
child: Text(value),
|
||||
);
|
||||
})
|
||||
.toList(),
|
||||
@@ -336,12 +336,12 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
bool iconButtonToggle = false;
|
||||
|
||||
Widget buildIconButton() {
|
||||
return new Align(
|
||||
return Align(
|
||||
alignment: const Alignment(0.0, -0.2),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.thumb_up,
|
||||
semanticLabel: 'Thumbs up',
|
||||
@@ -359,16 +359,16 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
onPressed: null,
|
||||
)
|
||||
]
|
||||
.map((Widget button) => new SizedBox(width: 64.0, height: 64.0, child: button))
|
||||
.map((Widget button) => SizedBox(width: 64.0, height: 64.0, child: button))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildActionButton() {
|
||||
return new Align(
|
||||
return Align(
|
||||
alignment: const Alignment(0.0, -0.2),
|
||||
child: new FloatingActionButton(
|
||||
child: FloatingActionButton(
|
||||
child: const Icon(Icons.add),
|
||||
onPressed: () {
|
||||
// Perform some action
|
||||
|
||||
@@ -61,37 +61,37 @@ class TravelDestinationItem extends StatelessWidget {
|
||||
final TextStyle titleStyle = theme.textTheme.headline.copyWith(color: Colors.white);
|
||||
final TextStyle descriptionStyle = theme.textTheme.subhead;
|
||||
|
||||
return new SafeArea(
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Container(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
height: height,
|
||||
child: new Card(
|
||||
child: Card(
|
||||
shape: shape,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
// photo and title
|
||||
new SizedBox(
|
||||
SizedBox(
|
||||
height: 184.0,
|
||||
child: new Stack(
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
new Positioned.fill(
|
||||
child: new Image.asset(
|
||||
Positioned.fill(
|
||||
child: Image.asset(
|
||||
destination.assetName,
|
||||
package: destination.assetPackage,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
new Positioned(
|
||||
Positioned(
|
||||
bottom: 16.0,
|
||||
left: 16.0,
|
||||
right: 16.0,
|
||||
child: new FittedBox(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: Alignment.centerLeft,
|
||||
child: new Text(destination.title,
|
||||
child: Text(destination.title,
|
||||
style: titleStyle,
|
||||
),
|
||||
),
|
||||
@@ -100,42 +100,42 @@ class TravelDestinationItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
// description and share/explore buttons
|
||||
new Expanded(
|
||||
child: new Padding(
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 0.0),
|
||||
child: new DefaultTextStyle(
|
||||
child: DefaultTextStyle(
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: descriptionStyle,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
// three line description
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: new Text(
|
||||
child: Text(
|
||||
destination.description[0],
|
||||
style: descriptionStyle.copyWith(color: Colors.black54),
|
||||
),
|
||||
),
|
||||
new Text(destination.description[1]),
|
||||
new Text(destination.description[2]),
|
||||
Text(destination.description[1]),
|
||||
Text(destination.description[2]),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// share, explore buttons
|
||||
new ButtonTheme.bar(
|
||||
child: new ButtonBar(
|
||||
ButtonTheme.bar(
|
||||
child: ButtonBar(
|
||||
alignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('SHARE'),
|
||||
textColor: Colors.amber.shade500,
|
||||
onPressed: () { /* do nothing */ },
|
||||
),
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('EXPLORE'),
|
||||
textColor: Colors.amber.shade500,
|
||||
onPressed: () { /* do nothing */ },
|
||||
@@ -156,7 +156,7 @@ class CardsDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/cards';
|
||||
|
||||
@override
|
||||
_CardsDemoState createState() => new _CardsDemoState();
|
||||
_CardsDemoState createState() => _CardsDemoState();
|
||||
}
|
||||
|
||||
class _CardsDemoState extends State<CardsDemo> {
|
||||
@@ -164,11 +164,11 @@ class _CardsDemoState extends State<CardsDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Travel stream'),
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.sentiment_very_satisfied),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@@ -185,13 +185,13 @@ class _CardsDemoState extends State<CardsDemo> {
|
||||
),
|
||||
],
|
||||
),
|
||||
body: new ListView(
|
||||
body: ListView(
|
||||
itemExtent: TravelDestinationItem.height,
|
||||
padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0),
|
||||
children: destinations.map((TravelDestination destination) {
|
||||
return new Container(
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 8.0),
|
||||
child: new TravelDestinationItem(
|
||||
child: TravelDestinationItem(
|
||||
destination: destination,
|
||||
shape: _shape,
|
||||
),
|
||||
|
||||
@@ -53,19 +53,19 @@ const Map<String, String> _avatars = <String, String>{
|
||||
};
|
||||
|
||||
final Map<String, Set<String>> _toolActions = <String, Set<String>>{
|
||||
'hammer': new Set<String>()..addAll(<String>['flake', 'fragment', 'splinter']),
|
||||
'chisel': new Set<String>()..addAll(<String>['flake', 'nick', 'splinter']),
|
||||
'fryer': new Set<String>()..addAll(<String>['fry']),
|
||||
'fabricator': new Set<String>()..addAll(<String>['solder']),
|
||||
'customer': new Set<String>()..addAll(<String>['cash in', 'eat']),
|
||||
'hammer': Set<String>()..addAll(<String>['flake', 'fragment', 'splinter']),
|
||||
'chisel': Set<String>()..addAll(<String>['flake', 'nick', 'splinter']),
|
||||
'fryer': Set<String>()..addAll(<String>['fry']),
|
||||
'fabricator': Set<String>()..addAll(<String>['solder']),
|
||||
'customer': Set<String>()..addAll(<String>['cash in', 'eat']),
|
||||
};
|
||||
|
||||
final Map<String, Set<String>> _materialActions = <String, Set<String>>{
|
||||
'poker': new Set<String>()..addAll(<String>['cash in']),
|
||||
'tortilla': new Set<String>()..addAll(<String>['fry', 'eat']),
|
||||
'fish and': new Set<String>()..addAll(<String>['fry', 'eat']),
|
||||
'micro': new Set<String>()..addAll(<String>['solder', 'fragment']),
|
||||
'wood': new Set<String>()..addAll(<String>['flake', 'cut', 'splinter', 'nick']),
|
||||
'poker': Set<String>()..addAll(<String>['cash in']),
|
||||
'tortilla': Set<String>()..addAll(<String>['fry', 'eat']),
|
||||
'fish and': Set<String>()..addAll(<String>['fry', 'eat']),
|
||||
'micro': Set<String>()..addAll(<String>['solder', 'fragment']),
|
||||
'wood': Set<String>()..addAll(<String>['flake', 'cut', 'splinter', 'nick']),
|
||||
};
|
||||
|
||||
class _ChipsTile extends StatelessWidget {
|
||||
@@ -82,16 +82,16 @@ class _ChipsTile extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<Widget> cardChildren = <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
padding: const EdgeInsets.only(top: 16.0, bottom: 4.0),
|
||||
alignment: Alignment.center,
|
||||
child: new Text(label, textAlign: TextAlign.start),
|
||||
child: Text(label, textAlign: TextAlign.start),
|
||||
),
|
||||
];
|
||||
if (children.isNotEmpty) {
|
||||
cardChildren.add(new Wrap(
|
||||
cardChildren.add(Wrap(
|
||||
children: children.map((Widget chip) {
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(2.0),
|
||||
child: chip,
|
||||
);
|
||||
@@ -99,20 +99,20 @@ class _ChipsTile extends StatelessWidget {
|
||||
} else {
|
||||
final TextStyle textStyle = Theme.of(context).textTheme.caption.copyWith(fontStyle: FontStyle.italic);
|
||||
cardChildren.add(
|
||||
new Semantics(
|
||||
Semantics(
|
||||
container: true,
|
||||
child: new Container(
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
constraints: const BoxConstraints(minWidth: 48.0, minHeight: 48.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Text('None', style: textStyle),
|
||||
child: Text('None', style: textStyle),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
return new Card(
|
||||
return Card(
|
||||
semanticContainer: false,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: cardChildren,
|
||||
)
|
||||
@@ -124,7 +124,7 @@ class ChipDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/chip';
|
||||
|
||||
@override
|
||||
_ChipDemoState createState() => new _ChipDemoState();
|
||||
_ChipDemoState createState() => _ChipDemoState();
|
||||
}
|
||||
|
||||
class _ChipDemoState extends State<ChipDemo> {
|
||||
@@ -132,12 +132,12 @@ class _ChipDemoState extends State<ChipDemo> {
|
||||
_reset();
|
||||
}
|
||||
|
||||
final Set<String> _materials = new Set<String>();
|
||||
final Set<String> _materials = Set<String>();
|
||||
String _selectedMaterial = '';
|
||||
String _selectedAction = '';
|
||||
final Set<String> _tools = new Set<String>();
|
||||
final Set<String> _selectedTools = new Set<String>();
|
||||
final Set<String> _actions = new Set<String>();
|
||||
final Set<String> _tools = Set<String>();
|
||||
final Set<String> _selectedTools = Set<String>();
|
||||
final Set<String> _actions = Set<String>();
|
||||
bool _showShapeBorder = false;
|
||||
|
||||
// Initialize members with the default data.
|
||||
@@ -180,12 +180,12 @@ class _ChipDemoState extends State<ChipDemo> {
|
||||
assert(name.length > 1);
|
||||
final int hash = name.hashCode & 0xffff;
|
||||
final double hue = (360.0 * hash / (1 << 15)) % 360.0;
|
||||
return new HSVColor.fromAHSV(1.0, hue, 0.4, 0.90).toColor();
|
||||
return HSVColor.fromAHSV(1.0, hue, 0.4, 0.90).toColor();
|
||||
}
|
||||
|
||||
AssetImage _nameToAvatar(String name) {
|
||||
assert(_avatars.containsKey(name));
|
||||
return new AssetImage(
|
||||
return AssetImage(
|
||||
_avatars[name],
|
||||
package: 'flutter_gallery_assets',
|
||||
);
|
||||
@@ -201,10 +201,10 @@ class _ChipDemoState extends State<ChipDemo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<Widget> chips = _materials.map<Widget>((String name) {
|
||||
return new Chip(
|
||||
key: new ValueKey<String>(name),
|
||||
return Chip(
|
||||
key: ValueKey<String>(name),
|
||||
backgroundColor: _nameToColor(name),
|
||||
label: new Text(_capitalize(name)),
|
||||
label: Text(_capitalize(name)),
|
||||
onDeleted: () {
|
||||
setState(() {
|
||||
_removeMaterial(name);
|
||||
@@ -214,12 +214,12 @@ class _ChipDemoState extends State<ChipDemo> {
|
||||
}).toList();
|
||||
|
||||
final List<Widget> inputChips = _tools.map<Widget>((String name) {
|
||||
return new InputChip(
|
||||
key: new ValueKey<String>(name),
|
||||
avatar: new CircleAvatar(
|
||||
return InputChip(
|
||||
key: ValueKey<String>(name),
|
||||
avatar: CircleAvatar(
|
||||
backgroundImage: _nameToAvatar(name),
|
||||
),
|
||||
label: new Text(_capitalize(name)),
|
||||
label: Text(_capitalize(name)),
|
||||
onDeleted: () {
|
||||
setState(() {
|
||||
_removeTool(name);
|
||||
@@ -228,10 +228,10 @@ class _ChipDemoState extends State<ChipDemo> {
|
||||
}).toList();
|
||||
|
||||
final List<Widget> choiceChips = _materials.map<Widget>((String name) {
|
||||
return new ChoiceChip(
|
||||
key: new ValueKey<String>(name),
|
||||
return ChoiceChip(
|
||||
key: ValueKey<String>(name),
|
||||
backgroundColor: _nameToColor(name),
|
||||
label: new Text(_capitalize(name)),
|
||||
label: Text(_capitalize(name)),
|
||||
selected: _selectedMaterial == name,
|
||||
onSelected: (bool value) {
|
||||
setState(() {
|
||||
@@ -242,9 +242,9 @@ class _ChipDemoState extends State<ChipDemo> {
|
||||
}).toList();
|
||||
|
||||
final List<Widget> filterChips = _defaultTools.map<Widget>((String name) {
|
||||
return new FilterChip(
|
||||
key: new ValueKey<String>(name),
|
||||
label: new Text(_capitalize(name)),
|
||||
return FilterChip(
|
||||
key: ValueKey<String>(name),
|
||||
label: Text(_capitalize(name)),
|
||||
selected: _tools.contains(name) ? _selectedTools.contains(name) : false,
|
||||
onSelected: !_tools.contains(name)
|
||||
? null
|
||||
@@ -260,7 +260,7 @@ class _ChipDemoState extends State<ChipDemo> {
|
||||
);
|
||||
}).toList();
|
||||
|
||||
Set<String> allowedActions = new Set<String>();
|
||||
Set<String> allowedActions = Set<String>();
|
||||
if (_selectedMaterial != null && _selectedMaterial.isNotEmpty) {
|
||||
for (String tool in _selectedTools) {
|
||||
allowedActions.addAll(_toolActions[tool]);
|
||||
@@ -269,8 +269,8 @@ class _ChipDemoState extends State<ChipDemo> {
|
||||
}
|
||||
|
||||
final List<Widget> actionChips = allowedActions.map<Widget>((String name) {
|
||||
return new ActionChip(
|
||||
label: new Text(_capitalize(name)),
|
||||
return ActionChip(
|
||||
label: Text(_capitalize(name)),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_selectedAction = name;
|
||||
@@ -282,16 +282,16 @@ class _ChipDemoState extends State<ChipDemo> {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final List<Widget> tiles = <Widget>[
|
||||
const SizedBox(height: 8.0, width: 0.0),
|
||||
new _ChipsTile(label: 'Available Materials (Chip)', children: chips),
|
||||
new _ChipsTile(label: 'Available Tools (InputChip)', children: inputChips),
|
||||
new _ChipsTile(label: 'Choose a Material (ChoiceChip)', children: choiceChips),
|
||||
new _ChipsTile(label: 'Choose Tools (FilterChip)', children: filterChips),
|
||||
new _ChipsTile(label: 'Perform Allowed Action (ActionChip)', children: actionChips),
|
||||
_ChipsTile(label: 'Available Materials (Chip)', children: chips),
|
||||
_ChipsTile(label: 'Available Tools (InputChip)', children: inputChips),
|
||||
_ChipsTile(label: 'Choose a Material (ChoiceChip)', children: choiceChips),
|
||||
_ChipsTile(label: 'Choose Tools (FilterChip)', children: filterChips),
|
||||
_ChipsTile(label: 'Perform Allowed Action (ActionChip)', children: actionChips),
|
||||
const Divider(),
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Center(
|
||||
child: new Text(
|
||||
child: Center(
|
||||
child: Text(
|
||||
_createResult(),
|
||||
style: theme.textTheme.title,
|
||||
),
|
||||
@@ -299,11 +299,11 @@ class _ChipDemoState extends State<ChipDemo> {
|
||||
),
|
||||
];
|
||||
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Chips'),
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_showShapeBorder = !_showShapeBorder;
|
||||
@@ -313,17 +313,17 @@ class _ChipDemoState extends State<ChipDemo> {
|
||||
)
|
||||
],
|
||||
),
|
||||
body: new ChipTheme(
|
||||
body: ChipTheme(
|
||||
data: _showShapeBorder
|
||||
? theme.chipTheme.copyWith(
|
||||
shape: new BeveledRectangleBorder(
|
||||
shape: BeveledRectangleBorder(
|
||||
side: const BorderSide(width: 0.66, style: BorderStyle.solid, color: Colors.grey),
|
||||
borderRadius: new BorderRadius.circular(10.0),
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
))
|
||||
: theme.chipTheme,
|
||||
child: new ListView(children: tiles),
|
||||
child: ListView(children: tiles),
|
||||
),
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => setState(_reset),
|
||||
child: const Icon(Icons.refresh, semanticLabel: 'Reset chips'),
|
||||
),
|
||||
|
||||
@@ -21,60 +21,60 @@ class Dessert {
|
||||
|
||||
class DessertDataSource extends DataTableSource {
|
||||
final List<Dessert> _desserts = <Dessert>[
|
||||
new Dessert('Frozen yogurt', 159, 6.0, 24, 4.0, 87, 14, 1),
|
||||
new Dessert('Ice cream sandwich', 237, 9.0, 37, 4.3, 129, 8, 1),
|
||||
new Dessert('Eclair', 262, 16.0, 24, 6.0, 337, 6, 7),
|
||||
new Dessert('Cupcake', 305, 3.7, 67, 4.3, 413, 3, 8),
|
||||
new Dessert('Gingerbread', 356, 16.0, 49, 3.9, 327, 7, 16),
|
||||
new Dessert('Jelly bean', 375, 0.0, 94, 0.0, 50, 0, 0),
|
||||
new Dessert('Lollipop', 392, 0.2, 98, 0.0, 38, 0, 2),
|
||||
new Dessert('Honeycomb', 408, 3.2, 87, 6.5, 562, 0, 45),
|
||||
new Dessert('Donut', 452, 25.0, 51, 4.9, 326, 2, 22),
|
||||
new Dessert('KitKat', 518, 26.0, 65, 7.0, 54, 12, 6),
|
||||
Dessert('Frozen yogurt', 159, 6.0, 24, 4.0, 87, 14, 1),
|
||||
Dessert('Ice cream sandwich', 237, 9.0, 37, 4.3, 129, 8, 1),
|
||||
Dessert('Eclair', 262, 16.0, 24, 6.0, 337, 6, 7),
|
||||
Dessert('Cupcake', 305, 3.7, 67, 4.3, 413, 3, 8),
|
||||
Dessert('Gingerbread', 356, 16.0, 49, 3.9, 327, 7, 16),
|
||||
Dessert('Jelly bean', 375, 0.0, 94, 0.0, 50, 0, 0),
|
||||
Dessert('Lollipop', 392, 0.2, 98, 0.0, 38, 0, 2),
|
||||
Dessert('Honeycomb', 408, 3.2, 87, 6.5, 562, 0, 45),
|
||||
Dessert('Donut', 452, 25.0, 51, 4.9, 326, 2, 22),
|
||||
Dessert('KitKat', 518, 26.0, 65, 7.0, 54, 12, 6),
|
||||
|
||||
new Dessert('Frozen yogurt with sugar', 168, 6.0, 26, 4.0, 87, 14, 1),
|
||||
new Dessert('Ice cream sandwich with sugar', 246, 9.0, 39, 4.3, 129, 8, 1),
|
||||
new Dessert('Eclair with sugar', 271, 16.0, 26, 6.0, 337, 6, 7),
|
||||
new Dessert('Cupcake with sugar', 314, 3.7, 69, 4.3, 413, 3, 8),
|
||||
new Dessert('Gingerbread with sugar', 345, 16.0, 51, 3.9, 327, 7, 16),
|
||||
new Dessert('Jelly bean with sugar', 364, 0.0, 96, 0.0, 50, 0, 0),
|
||||
new Dessert('Lollipop with sugar', 401, 0.2, 100, 0.0, 38, 0, 2),
|
||||
new Dessert('Honeycomb with sugar', 417, 3.2, 89, 6.5, 562, 0, 45),
|
||||
new Dessert('Donut with sugar', 461, 25.0, 53, 4.9, 326, 2, 22),
|
||||
new Dessert('KitKat with sugar', 527, 26.0, 67, 7.0, 54, 12, 6),
|
||||
Dessert('Frozen yogurt with sugar', 168, 6.0, 26, 4.0, 87, 14, 1),
|
||||
Dessert('Ice cream sandwich with sugar', 246, 9.0, 39, 4.3, 129, 8, 1),
|
||||
Dessert('Eclair with sugar', 271, 16.0, 26, 6.0, 337, 6, 7),
|
||||
Dessert('Cupcake with sugar', 314, 3.7, 69, 4.3, 413, 3, 8),
|
||||
Dessert('Gingerbread with sugar', 345, 16.0, 51, 3.9, 327, 7, 16),
|
||||
Dessert('Jelly bean with sugar', 364, 0.0, 96, 0.0, 50, 0, 0),
|
||||
Dessert('Lollipop with sugar', 401, 0.2, 100, 0.0, 38, 0, 2),
|
||||
Dessert('Honeycomb with sugar', 417, 3.2, 89, 6.5, 562, 0, 45),
|
||||
Dessert('Donut with sugar', 461, 25.0, 53, 4.9, 326, 2, 22),
|
||||
Dessert('KitKat with sugar', 527, 26.0, 67, 7.0, 54, 12, 6),
|
||||
|
||||
new Dessert('Frozen yogurt with honey', 223, 6.0, 36, 4.0, 87, 14, 1),
|
||||
new Dessert('Ice cream sandwich with honey', 301, 9.0, 49, 4.3, 129, 8, 1),
|
||||
new Dessert('Eclair with honey', 326, 16.0, 36, 6.0, 337, 6, 7),
|
||||
new Dessert('Cupcake with honey', 369, 3.7, 79, 4.3, 413, 3, 8),
|
||||
new Dessert('Gingerbread with honey', 420, 16.0, 61, 3.9, 327, 7, 16),
|
||||
new Dessert('Jelly bean with honey', 439, 0.0, 106, 0.0, 50, 0, 0),
|
||||
new Dessert('Lollipop with honey', 456, 0.2, 110, 0.0, 38, 0, 2),
|
||||
new Dessert('Honeycomb with honey', 472, 3.2, 99, 6.5, 562, 0, 45),
|
||||
new Dessert('Donut with honey', 516, 25.0, 63, 4.9, 326, 2, 22),
|
||||
new Dessert('KitKat with honey', 582, 26.0, 77, 7.0, 54, 12, 6),
|
||||
Dessert('Frozen yogurt with honey', 223, 6.0, 36, 4.0, 87, 14, 1),
|
||||
Dessert('Ice cream sandwich with honey', 301, 9.0, 49, 4.3, 129, 8, 1),
|
||||
Dessert('Eclair with honey', 326, 16.0, 36, 6.0, 337, 6, 7),
|
||||
Dessert('Cupcake with honey', 369, 3.7, 79, 4.3, 413, 3, 8),
|
||||
Dessert('Gingerbread with honey', 420, 16.0, 61, 3.9, 327, 7, 16),
|
||||
Dessert('Jelly bean with honey', 439, 0.0, 106, 0.0, 50, 0, 0),
|
||||
Dessert('Lollipop with honey', 456, 0.2, 110, 0.0, 38, 0, 2),
|
||||
Dessert('Honeycomb with honey', 472, 3.2, 99, 6.5, 562, 0, 45),
|
||||
Dessert('Donut with honey', 516, 25.0, 63, 4.9, 326, 2, 22),
|
||||
Dessert('KitKat with honey', 582, 26.0, 77, 7.0, 54, 12, 6),
|
||||
|
||||
new Dessert('Frozen yogurt with milk', 262, 8.4, 36, 12.0, 194, 44, 1),
|
||||
new Dessert('Ice cream sandwich with milk', 339, 11.4, 49, 12.3, 236, 38, 1),
|
||||
new Dessert('Eclair with milk', 365, 18.4, 36, 14.0, 444, 36, 7),
|
||||
new Dessert('Cupcake with milk', 408, 6.1, 79, 12.3, 520, 33, 8),
|
||||
new Dessert('Gingerbread with milk', 459, 18.4, 61, 11.9, 434, 37, 16),
|
||||
new Dessert('Jelly bean with milk', 478, 2.4, 106, 8.0, 157, 30, 0),
|
||||
new Dessert('Lollipop with milk', 495, 2.6, 110, 8.0, 145, 30, 2),
|
||||
new Dessert('Honeycomb with milk', 511, 5.6, 99, 14.5, 669, 30, 45),
|
||||
new Dessert('Donut with milk', 555, 27.4, 63, 12.9, 433, 32, 22),
|
||||
new Dessert('KitKat with milk', 621, 28.4, 77, 15.0, 161, 42, 6),
|
||||
Dessert('Frozen yogurt with milk', 262, 8.4, 36, 12.0, 194, 44, 1),
|
||||
Dessert('Ice cream sandwich with milk', 339, 11.4, 49, 12.3, 236, 38, 1),
|
||||
Dessert('Eclair with milk', 365, 18.4, 36, 14.0, 444, 36, 7),
|
||||
Dessert('Cupcake with milk', 408, 6.1, 79, 12.3, 520, 33, 8),
|
||||
Dessert('Gingerbread with milk', 459, 18.4, 61, 11.9, 434, 37, 16),
|
||||
Dessert('Jelly bean with milk', 478, 2.4, 106, 8.0, 157, 30, 0),
|
||||
Dessert('Lollipop with milk', 495, 2.6, 110, 8.0, 145, 30, 2),
|
||||
Dessert('Honeycomb with milk', 511, 5.6, 99, 14.5, 669, 30, 45),
|
||||
Dessert('Donut with milk', 555, 27.4, 63, 12.9, 433, 32, 22),
|
||||
Dessert('KitKat with milk', 621, 28.4, 77, 15.0, 161, 42, 6),
|
||||
|
||||
new Dessert('Coconut slice and frozen yogurt', 318, 21.0, 31, 5.5, 96, 14, 7),
|
||||
new Dessert('Coconut slice and ice cream sandwich', 396, 24.0, 44, 5.8, 138, 8, 7),
|
||||
new Dessert('Coconut slice and eclair', 421, 31.0, 31, 7.5, 346, 6, 13),
|
||||
new Dessert('Coconut slice and cupcake', 464, 18.7, 74, 5.8, 422, 3, 14),
|
||||
new Dessert('Coconut slice and gingerbread', 515, 31.0, 56, 5.4, 316, 7, 22),
|
||||
new Dessert('Coconut slice and jelly bean', 534, 15.0, 101, 1.5, 59, 0, 6),
|
||||
new Dessert('Coconut slice and lollipop', 551, 15.2, 105, 1.5, 47, 0, 8),
|
||||
new Dessert('Coconut slice and honeycomb', 567, 18.2, 94, 8.0, 571, 0, 51),
|
||||
new Dessert('Coconut slice and donut', 611, 40.0, 58, 6.4, 335, 2, 28),
|
||||
new Dessert('Coconut slice and KitKat', 677, 41.0, 72, 8.5, 63, 12, 12),
|
||||
Dessert('Coconut slice and frozen yogurt', 318, 21.0, 31, 5.5, 96, 14, 7),
|
||||
Dessert('Coconut slice and ice cream sandwich', 396, 24.0, 44, 5.8, 138, 8, 7),
|
||||
Dessert('Coconut slice and eclair', 421, 31.0, 31, 7.5, 346, 6, 13),
|
||||
Dessert('Coconut slice and cupcake', 464, 18.7, 74, 5.8, 422, 3, 14),
|
||||
Dessert('Coconut slice and gingerbread', 515, 31.0, 56, 5.4, 316, 7, 22),
|
||||
Dessert('Coconut slice and jelly bean', 534, 15.0, 101, 1.5, 59, 0, 6),
|
||||
Dessert('Coconut slice and lollipop', 551, 15.2, 105, 1.5, 47, 0, 8),
|
||||
Dessert('Coconut slice and honeycomb', 567, 18.2, 94, 8.0, 571, 0, 51),
|
||||
Dessert('Coconut slice and donut', 611, 40.0, 58, 6.4, 335, 2, 28),
|
||||
Dessert('Coconut slice and KitKat', 677, 41.0, 72, 8.5, 63, 12, 12),
|
||||
];
|
||||
|
||||
void _sort<T>(Comparable<T> getField(Dessert d), bool ascending) {
|
||||
@@ -99,7 +99,7 @@ class DessertDataSource extends DataTableSource {
|
||||
if (index >= _desserts.length)
|
||||
return null;
|
||||
final Dessert dessert = _desserts[index];
|
||||
return new DataRow.byIndex(
|
||||
return DataRow.byIndex(
|
||||
index: index,
|
||||
selected: dessert.selected,
|
||||
onSelectChanged: (bool value) {
|
||||
@@ -111,14 +111,14 @@ class DessertDataSource extends DataTableSource {
|
||||
}
|
||||
},
|
||||
cells: <DataCell>[
|
||||
new DataCell(new Text('${dessert.name}')),
|
||||
new DataCell(new Text('${dessert.calories}')),
|
||||
new DataCell(new Text('${dessert.fat.toStringAsFixed(1)}')),
|
||||
new DataCell(new Text('${dessert.carbs}')),
|
||||
new DataCell(new Text('${dessert.protein.toStringAsFixed(1)}')),
|
||||
new DataCell(new Text('${dessert.sodium}')),
|
||||
new DataCell(new Text('${dessert.calcium}%')),
|
||||
new DataCell(new Text('${dessert.iron}%')),
|
||||
DataCell(Text('${dessert.name}')),
|
||||
DataCell(Text('${dessert.calories}')),
|
||||
DataCell(Text('${dessert.fat.toStringAsFixed(1)}')),
|
||||
DataCell(Text('${dessert.carbs}')),
|
||||
DataCell(Text('${dessert.protein.toStringAsFixed(1)}')),
|
||||
DataCell(Text('${dessert.sodium}')),
|
||||
DataCell(Text('${dessert.calcium}%')),
|
||||
DataCell(Text('${dessert.iron}%')),
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -144,14 +144,14 @@ class DataTableDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/data-table';
|
||||
|
||||
@override
|
||||
_DataTableDemoState createState() => new _DataTableDemoState();
|
||||
_DataTableDemoState createState() => _DataTableDemoState();
|
||||
}
|
||||
|
||||
class _DataTableDemoState extends State<DataTableDemo> {
|
||||
int _rowsPerPage = PaginatedDataTable.defaultRowsPerPage;
|
||||
int _sortColumnIndex;
|
||||
bool _sortAscending = true;
|
||||
final DessertDataSource _dessertsDataSource = new DessertDataSource();
|
||||
final DessertDataSource _dessertsDataSource = DessertDataSource();
|
||||
|
||||
void _sort<T>(Comparable<T> getField(Dessert d), int columnIndex, bool ascending) {
|
||||
_dessertsDataSource._sort<T>(getField, ascending);
|
||||
@@ -163,12 +163,12 @@ class _DataTableDemoState extends State<DataTableDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: const Text('Data tables')),
|
||||
body: new ListView(
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Data tables')),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
children: <Widget>[
|
||||
new PaginatedDataTable(
|
||||
PaginatedDataTable(
|
||||
header: const Text('Nutrition'),
|
||||
rowsPerPage: _rowsPerPage,
|
||||
onRowsPerPageChanged: (int value) { setState(() { _rowsPerPage = value; }); },
|
||||
@@ -176,43 +176,43 @@ class _DataTableDemoState extends State<DataTableDemo> {
|
||||
sortAscending: _sortAscending,
|
||||
onSelectAll: _dessertsDataSource._selectAll,
|
||||
columns: <DataColumn>[
|
||||
new DataColumn(
|
||||
DataColumn(
|
||||
label: const Text('Dessert (100g serving)'),
|
||||
onSort: (int columnIndex, bool ascending) => _sort<String>((Dessert d) => d.name, columnIndex, ascending)
|
||||
),
|
||||
new DataColumn(
|
||||
DataColumn(
|
||||
label: const Text('Calories'),
|
||||
tooltip: 'The total amount of food energy in the given serving size.',
|
||||
numeric: true,
|
||||
onSort: (int columnIndex, bool ascending) => _sort<num>((Dessert d) => d.calories, columnIndex, ascending)
|
||||
),
|
||||
new DataColumn(
|
||||
DataColumn(
|
||||
label: const Text('Fat (g)'),
|
||||
numeric: true,
|
||||
onSort: (int columnIndex, bool ascending) => _sort<num>((Dessert d) => d.fat, columnIndex, ascending)
|
||||
),
|
||||
new DataColumn(
|
||||
DataColumn(
|
||||
label: const Text('Carbs (g)'),
|
||||
numeric: true,
|
||||
onSort: (int columnIndex, bool ascending) => _sort<num>((Dessert d) => d.carbs, columnIndex, ascending)
|
||||
),
|
||||
new DataColumn(
|
||||
DataColumn(
|
||||
label: const Text('Protein (g)'),
|
||||
numeric: true,
|
||||
onSort: (int columnIndex, bool ascending) => _sort<num>((Dessert d) => d.protein, columnIndex, ascending)
|
||||
),
|
||||
new DataColumn(
|
||||
DataColumn(
|
||||
label: const Text('Sodium (mg)'),
|
||||
numeric: true,
|
||||
onSort: (int columnIndex, bool ascending) => _sort<num>((Dessert d) => d.sodium, columnIndex, ascending)
|
||||
),
|
||||
new DataColumn(
|
||||
DataColumn(
|
||||
label: const Text('Calcium (%)'),
|
||||
tooltip: 'The amount of calcium as a percentage of the recommended daily amount.',
|
||||
numeric: true,
|
||||
onSort: (int columnIndex, bool ascending) => _sort<num>((Dessert d) => d.calcium, columnIndex, ascending)
|
||||
),
|
||||
new DataColumn(
|
||||
DataColumn(
|
||||
label: const Text('Iron (%)'),
|
||||
numeric: true,
|
||||
onSort: (int columnIndex, bool ascending) => _sort<num>((Dessert d) => d.iron, columnIndex, ascending)
|
||||
|
||||
@@ -24,19 +24,19 @@ class _InputDropdown extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new InkWell(
|
||||
return InkWell(
|
||||
onTap: onPressed,
|
||||
child: new InputDecorator(
|
||||
decoration: new InputDecoration(
|
||||
child: InputDecorator(
|
||||
decoration: InputDecoration(
|
||||
labelText: labelText,
|
||||
),
|
||||
baseStyle: valueStyle,
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Text(valueText, style: valueStyle),
|
||||
new Icon(Icons.arrow_drop_down,
|
||||
Text(valueText, style: valueStyle),
|
||||
Icon(Icons.arrow_drop_down,
|
||||
color: Theme.of(context).brightness == Brightness.light ? Colors.grey.shade700 : Colors.white70
|
||||
),
|
||||
],
|
||||
@@ -66,8 +66,8 @@ class _DateTimePicker extends StatelessWidget {
|
||||
final DateTime picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: selectedDate,
|
||||
firstDate: new DateTime(2015, 8),
|
||||
lastDate: new DateTime(2101)
|
||||
firstDate: DateTime(2015, 8),
|
||||
lastDate: DateTime(2101)
|
||||
);
|
||||
if (picked != null && picked != selectedDate)
|
||||
selectDate(picked);
|
||||
@@ -85,22 +85,22 @@ class _DateTimePicker extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final TextStyle valueStyle = Theme.of(context).textTheme.title;
|
||||
return new Row(
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: new _InputDropdown(
|
||||
child: _InputDropdown(
|
||||
labelText: labelText,
|
||||
valueText: new DateFormat.yMMMd().format(selectedDate),
|
||||
valueText: DateFormat.yMMMd().format(selectedDate),
|
||||
valueStyle: valueStyle,
|
||||
onPressed: () { _selectDate(context); },
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12.0),
|
||||
new Expanded(
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: new _InputDropdown(
|
||||
child: _InputDropdown(
|
||||
valueText: selectedTime.format(context),
|
||||
valueStyle: valueStyle,
|
||||
onPressed: () { _selectTime(context); },
|
||||
@@ -115,29 +115,29 @@ class DateAndTimePickerDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/date-and-time-pickers';
|
||||
|
||||
@override
|
||||
_DateAndTimePickerDemoState createState() => new _DateAndTimePickerDemoState();
|
||||
_DateAndTimePickerDemoState createState() => _DateAndTimePickerDemoState();
|
||||
}
|
||||
|
||||
class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
|
||||
DateTime _fromDate = new DateTime.now();
|
||||
DateTime _fromDate = DateTime.now();
|
||||
TimeOfDay _fromTime = const TimeOfDay(hour: 7, minute: 28);
|
||||
DateTime _toDate = new DateTime.now();
|
||||
DateTime _toDate = DateTime.now();
|
||||
TimeOfDay _toTime = const TimeOfDay(hour: 7, minute: 28);
|
||||
final List<String> _allActivities = <String>['hiking', 'swimming', 'boating', 'fishing'];
|
||||
String _activity = 'fishing';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: const Text('Date and time pickers')),
|
||||
body: new DropdownButtonHideUnderline(
|
||||
child: new SafeArea(
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Date and time pickers')),
|
||||
body: DropdownButtonHideUnderline(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new ListView(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
children: <Widget>[
|
||||
new TextField(
|
||||
TextField(
|
||||
enabled: true,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Event name',
|
||||
@@ -145,13 +145,13 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
|
||||
),
|
||||
style: Theme.of(context).textTheme.display1,
|
||||
),
|
||||
new TextField(
|
||||
TextField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Location',
|
||||
),
|
||||
style: Theme.of(context).textTheme.display1.copyWith(fontSize: 20.0),
|
||||
),
|
||||
new _DateTimePicker(
|
||||
_DateTimePicker(
|
||||
labelText: 'From',
|
||||
selectedDate: _fromDate,
|
||||
selectedTime: _fromTime,
|
||||
@@ -166,7 +166,7 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
|
||||
});
|
||||
},
|
||||
),
|
||||
new _DateTimePicker(
|
||||
_DateTimePicker(
|
||||
labelText: 'To',
|
||||
selectedDate: _toDate,
|
||||
selectedTime: _toTime,
|
||||
@@ -181,13 +181,13 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
|
||||
});
|
||||
},
|
||||
),
|
||||
new InputDecorator(
|
||||
InputDecorator(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Activity',
|
||||
hintText: 'Choose an activity',
|
||||
),
|
||||
isEmpty: _activity == null,
|
||||
child: new DropdownButton<String>(
|
||||
child: DropdownButton<String>(
|
||||
value: _activity,
|
||||
isDense: true,
|
||||
onChanged: (String newValue) {
|
||||
@@ -196,9 +196,9 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
|
||||
});
|
||||
},
|
||||
items: _allActivities.map((String value) {
|
||||
return new DropdownMenuItem<String>(
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: new Text(value),
|
||||
child: Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
|
||||
@@ -29,16 +29,16 @@ class DialogDemoItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new SimpleDialogOption(
|
||||
return SimpleDialogOption(
|
||||
onPressed: onPressed,
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
new Icon(icon, size: 36.0, color: color),
|
||||
new Padding(
|
||||
Icon(icon, size: 36.0, color: color),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16.0),
|
||||
child: new Text(text),
|
||||
child: Text(text),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -50,19 +50,19 @@ class DialogDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/dialog';
|
||||
|
||||
@override
|
||||
DialogDemoState createState() => new DialogDemoState();
|
||||
DialogDemoState createState() => DialogDemoState();
|
||||
}
|
||||
|
||||
class DialogDemoState extends State<DialogDemo> {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
TimeOfDay _selectedTime;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final DateTime now = new DateTime.now();
|
||||
_selectedTime = new TimeOfDay(hour: now.hour, minute: now.minute);
|
||||
final DateTime now = DateTime.now();
|
||||
_selectedTime = TimeOfDay(hour: now.hour, minute: now.minute);
|
||||
}
|
||||
|
||||
void showDemoDialog<T>({ BuildContext context, Widget child }) {
|
||||
@@ -72,8 +72,8 @@ class DialogDemoState extends State<DialogDemo> {
|
||||
)
|
||||
.then<void>((T value) { // The value passed to Navigator.pop() or null.
|
||||
if (value != null) {
|
||||
_scaffoldKey.currentState.showSnackBar(new SnackBar(
|
||||
content: new Text('You selected: $value')
|
||||
_scaffoldKey.currentState.showSnackBar(SnackBar(
|
||||
content: Text('You selected: $value')
|
||||
));
|
||||
}
|
||||
});
|
||||
@@ -84,30 +84,30 @@ class DialogDemoState extends State<DialogDemo> {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final TextStyle dialogTextStyle = theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color);
|
||||
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: new AppBar(
|
||||
appBar: AppBar(
|
||||
title: const Text('Dialogs')
|
||||
),
|
||||
body: new ListView(
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0),
|
||||
children: <Widget>[
|
||||
new RaisedButton(
|
||||
RaisedButton(
|
||||
child: const Text('ALERT'),
|
||||
onPressed: () {
|
||||
showDemoDialog<DialogDemoAction>(
|
||||
context: context,
|
||||
child: new AlertDialog(
|
||||
content: new Text(
|
||||
child: AlertDialog(
|
||||
content: Text(
|
||||
_alertWithoutTitleText,
|
||||
style: dialogTextStyle
|
||||
),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('CANCEL'),
|
||||
onPressed: () { Navigator.pop(context, DialogDemoAction.cancel); }
|
||||
),
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('DISCARD'),
|
||||
onPressed: () { Navigator.pop(context, DialogDemoAction.discard); }
|
||||
)
|
||||
@@ -116,23 +116,23 @@ class DialogDemoState extends State<DialogDemo> {
|
||||
);
|
||||
}
|
||||
),
|
||||
new RaisedButton(
|
||||
RaisedButton(
|
||||
child: const Text('ALERT WITH TITLE'),
|
||||
onPressed: () {
|
||||
showDemoDialog<DialogDemoAction>(
|
||||
context: context,
|
||||
child: new AlertDialog(
|
||||
child: AlertDialog(
|
||||
title: const Text('Use Google\'s location service?'),
|
||||
content: new Text(
|
||||
content: Text(
|
||||
_alertWithTitleText,
|
||||
style: dialogTextStyle
|
||||
),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('DISAGREE'),
|
||||
onPressed: () { Navigator.pop(context, DialogDemoAction.disagree); }
|
||||
),
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('AGREE'),
|
||||
onPressed: () { Navigator.pop(context, DialogDemoAction.agree); }
|
||||
)
|
||||
@@ -141,27 +141,27 @@ class DialogDemoState extends State<DialogDemo> {
|
||||
);
|
||||
}
|
||||
),
|
||||
new RaisedButton(
|
||||
RaisedButton(
|
||||
child: const Text('SIMPLE'),
|
||||
onPressed: () {
|
||||
showDemoDialog<String>(
|
||||
context: context,
|
||||
child: new SimpleDialog(
|
||||
child: SimpleDialog(
|
||||
title: const Text('Set backup account'),
|
||||
children: <Widget>[
|
||||
new DialogDemoItem(
|
||||
DialogDemoItem(
|
||||
icon: Icons.account_circle,
|
||||
color: theme.primaryColor,
|
||||
text: 'username@gmail.com',
|
||||
onPressed: () { Navigator.pop(context, 'username@gmail.com'); }
|
||||
),
|
||||
new DialogDemoItem(
|
||||
DialogDemoItem(
|
||||
icon: Icons.account_circle,
|
||||
color: theme.primaryColor,
|
||||
text: 'user02@gmail.com',
|
||||
onPressed: () { Navigator.pop(context, 'user02@gmail.com'); }
|
||||
),
|
||||
new DialogDemoItem(
|
||||
DialogDemoItem(
|
||||
icon: Icons.add_circle,
|
||||
text: 'add account',
|
||||
color: theme.disabledColor
|
||||
@@ -171,7 +171,7 @@ class DialogDemoState extends State<DialogDemo> {
|
||||
);
|
||||
}
|
||||
),
|
||||
new RaisedButton(
|
||||
RaisedButton(
|
||||
child: const Text('CONFIRMATION'),
|
||||
onPressed: () {
|
||||
showTimePicker(
|
||||
@@ -181,18 +181,18 @@ class DialogDemoState extends State<DialogDemo> {
|
||||
.then<Null>((TimeOfDay value) {
|
||||
if (value != null && value != _selectedTime) {
|
||||
_selectedTime = value;
|
||||
_scaffoldKey.currentState.showSnackBar(new SnackBar(
|
||||
content: new Text('You selected: ${value.format(context)}')
|
||||
_scaffoldKey.currentState.showSnackBar(SnackBar(
|
||||
content: Text('You selected: ${value.format(context)}')
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
),
|
||||
new RaisedButton(
|
||||
RaisedButton(
|
||||
child: const Text('FULLSCREEN'),
|
||||
onPressed: () {
|
||||
Navigator.push(context, new MaterialPageRoute<DismissDialogAction>(
|
||||
builder: (BuildContext context) => new FullScreenDialogDemo(),
|
||||
Navigator.push(context, MaterialPageRoute<DismissDialogAction>(
|
||||
builder: (BuildContext context) => FullScreenDialogDemo(),
|
||||
fullscreenDialog: true,
|
||||
));
|
||||
}
|
||||
@@ -200,7 +200,7 @@ class DialogDemoState extends State<DialogDemo> {
|
||||
]
|
||||
// Add a little space between the buttons
|
||||
.map((Widget button) {
|
||||
return new Container(
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: button
|
||||
);
|
||||
|
||||
@@ -13,11 +13,11 @@ class DrawerDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/drawer';
|
||||
|
||||
@override
|
||||
_DrawerDemoState createState() => new _DrawerDemoState();
|
||||
_DrawerDemoState createState() => _DrawerDemoState();
|
||||
}
|
||||
|
||||
class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
static const List<String> _drawerContents = <String>[
|
||||
'A', 'B', 'C', 'D', 'E',
|
||||
@@ -31,18 +31,18 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = new AnimationController(
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
);
|
||||
_drawerContentsOpacity = new CurvedAnimation(
|
||||
parent: new ReverseAnimation(_controller),
|
||||
_drawerContentsOpacity = CurvedAnimation(
|
||||
parent: ReverseAnimation(_controller),
|
||||
curve: Curves.fastOutSlowIn,
|
||||
);
|
||||
_drawerDetailsPosition = new Tween<Offset>(
|
||||
_drawerDetailsPosition = Tween<Offset>(
|
||||
begin: const Offset(0.0, -1.0),
|
||||
end: Offset.zero,
|
||||
).animate(new CurvedAnimation(
|
||||
).animate(CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: Curves.fastOutSlowIn,
|
||||
));
|
||||
@@ -75,11 +75,11 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: new AppBar(
|
||||
leading: new IconButton(
|
||||
icon: new Icon(_backIcon()),
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: Icon(_backIcon()),
|
||||
alignment: Alignment.centerLeft,
|
||||
tooltip: 'Back',
|
||||
onPressed: () {
|
||||
@@ -88,10 +88,10 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
||||
),
|
||||
title: const Text('Navigation drawer'),
|
||||
),
|
||||
drawer: new Drawer(
|
||||
child: new Column(
|
||||
drawer: Drawer(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new UserAccountsDrawerHeader(
|
||||
UserAccountsDrawerHeader(
|
||||
accountName: const Text('Trevor Widget'),
|
||||
accountEmail: const Text('trevor.widget@example.com'),
|
||||
currentAccountPicture: const CircleAvatar(
|
||||
@@ -101,11 +101,11 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
||||
),
|
||||
),
|
||||
otherAccountsPictures: <Widget>[
|
||||
new GestureDetector(
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
_onOtherAccountsTap(context);
|
||||
},
|
||||
child: new Semantics(
|
||||
child: Semantics(
|
||||
label: 'Switch to Account B',
|
||||
child: const CircleAvatar(
|
||||
backgroundImage: AssetImage(
|
||||
@@ -115,11 +115,11 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
||||
),
|
||||
),
|
||||
),
|
||||
new GestureDetector(
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
_onOtherAccountsTap(context);
|
||||
},
|
||||
child: new Semantics(
|
||||
child: Semantics(
|
||||
label: 'Switch to Account C',
|
||||
child: const CircleAvatar(
|
||||
backgroundImage: AssetImage(
|
||||
@@ -139,46 +139,46 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
||||
_controller.forward();
|
||||
},
|
||||
),
|
||||
new MediaQuery.removePadding(
|
||||
MediaQuery.removePadding(
|
||||
context: context,
|
||||
// DrawerHeader consumes top MediaQuery padding.
|
||||
removeTop: true,
|
||||
child: new Expanded(
|
||||
child: new ListView(
|
||||
child: Expanded(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
children: <Widget>[
|
||||
new Stack(
|
||||
Stack(
|
||||
children: <Widget>[
|
||||
// The initial contents of the drawer.
|
||||
new FadeTransition(
|
||||
FadeTransition(
|
||||
opacity: _drawerContentsOpacity,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: _drawerContents.map((String id) {
|
||||
return new ListTile(
|
||||
leading: new CircleAvatar(child: new Text(id)),
|
||||
title: new Text('Drawer item $id'),
|
||||
return ListTile(
|
||||
leading: CircleAvatar(child: Text(id)),
|
||||
title: Text('Drawer item $id'),
|
||||
onTap: _showNotImplementedMessage,
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
// The drawer's "details" view.
|
||||
new SlideTransition(
|
||||
SlideTransition(
|
||||
position: _drawerDetailsPosition,
|
||||
child: new FadeTransition(
|
||||
opacity: new ReverseAnimation(_drawerContentsOpacity),
|
||||
child: new Column(
|
||||
child: FadeTransition(
|
||||
opacity: ReverseAnimation(_drawerContentsOpacity),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
new ListTile(
|
||||
ListTile(
|
||||
leading: const Icon(Icons.add),
|
||||
title: const Text('Add account'),
|
||||
onTap: _showNotImplementedMessage,
|
||||
),
|
||||
new ListTile(
|
||||
ListTile(
|
||||
leading: const Icon(Icons.settings),
|
||||
title: const Text('Manage accounts'),
|
||||
onTap: _showNotImplementedMessage,
|
||||
@@ -196,19 +196,19 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
||||
],
|
||||
),
|
||||
),
|
||||
body: new Center(
|
||||
child: new InkWell(
|
||||
body: Center(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
_scaffoldKey.currentState.openDrawer();
|
||||
},
|
||||
child: new Semantics(
|
||||
child: Semantics(
|
||||
button: true,
|
||||
label: 'Open drawer',
|
||||
excludeSemantics: true,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
width: 100.0,
|
||||
height: 100.0,
|
||||
decoration: const BoxDecoration(
|
||||
@@ -221,9 +221,9 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
||||
),
|
||||
),
|
||||
),
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: new Text('Tap here to open the drawer',
|
||||
child: Text('Tap here to open the drawer',
|
||||
style: Theme.of(context).textTheme.subhead,
|
||||
),
|
||||
),
|
||||
@@ -239,10 +239,10 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return new AlertDialog(
|
||||
return AlertDialog(
|
||||
title: const Text('Account switching not implemented.'),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
|
||||
@@ -24,15 +24,15 @@ class _ElevationDemoState extends State<ElevationDemo> {
|
||||
];
|
||||
|
||||
return elevations.map((double elevation) {
|
||||
return new Center(
|
||||
child: new Card(
|
||||
return Center(
|
||||
child: Card(
|
||||
margin: const EdgeInsets.all(20.0),
|
||||
elevation: _showElevation ? elevation : 0.0,
|
||||
child: new SizedBox(
|
||||
child: SizedBox(
|
||||
height: 100.0,
|
||||
width: 100.0,
|
||||
child: new Center(
|
||||
child: new Text('${elevation.toStringAsFixed(0)} pt'),
|
||||
child: Center(
|
||||
child: Text('${elevation.toStringAsFixed(0)} pt'),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -42,11 +42,11 @@ class _ElevationDemoState extends State<ElevationDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Elevation'),
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.sentiment_very_satisfied),
|
||||
onPressed: () {
|
||||
setState(() => _showElevation = !_showElevation);
|
||||
@@ -54,7 +54,7 @@ class _ElevationDemoState extends State<ElevationDemo> {
|
||||
)
|
||||
],
|
||||
),
|
||||
body: new ListView(
|
||||
body: ListView(
|
||||
children: buildCards(),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -27,7 +27,7 @@ class DualHeaderWithHint extends StatelessWidget {
|
||||
final bool showHint;
|
||||
|
||||
Widget _crossFade(Widget first, Widget second, bool isExpanded) {
|
||||
return new AnimatedCrossFade(
|
||||
return AnimatedCrossFade(
|
||||
firstChild: first,
|
||||
secondChild: second,
|
||||
firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
|
||||
@@ -43,29 +43,29 @@ class DualHeaderWithHint extends StatelessWidget {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final TextTheme textTheme = theme.textTheme;
|
||||
|
||||
return new Row(
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: new Container(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(left: 24.0),
|
||||
child: new FittedBox(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: Alignment.centerLeft,
|
||||
child: new Text(
|
||||
child: Text(
|
||||
name,
|
||||
style: textTheme.body1.copyWith(fontSize: 15.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
new Expanded(
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: new Container(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(left: 24.0),
|
||||
child: _crossFade(
|
||||
new Text(value, style: textTheme.caption.copyWith(fontSize: 15.0)),
|
||||
new Text(hint, style: textTheme.caption.copyWith(fontSize: 15.0)),
|
||||
Text(value, style: textTheme.caption.copyWith(fontSize: 15.0)),
|
||||
Text(hint, style: textTheme.caption.copyWith(fontSize: 15.0)),
|
||||
showHint
|
||||
)
|
||||
)
|
||||
@@ -93,30 +93,30 @@ class CollapsibleBody extends StatelessWidget {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final TextTheme textTheme = theme.textTheme;
|
||||
|
||||
return new Column(
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
margin: const EdgeInsets.only(
|
||||
left: 24.0,
|
||||
right: 24.0,
|
||||
bottom: 24.0
|
||||
) - margin,
|
||||
child: new Center(
|
||||
child: new DefaultTextStyle(
|
||||
child: Center(
|
||||
child: DefaultTextStyle(
|
||||
style: textTheme.caption.copyWith(fontSize: 15.0),
|
||||
child: child
|
||||
)
|
||||
)
|
||||
),
|
||||
const Divider(height: 1.0),
|
||||
new Container(
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
margin: const EdgeInsets.only(right: 8.0),
|
||||
child: new FlatButton(
|
||||
child: FlatButton(
|
||||
onPressed: onCancel,
|
||||
child: const Text('CANCEL', style: TextStyle(
|
||||
color: Colors.black54,
|
||||
@@ -125,9 +125,9 @@ class CollapsibleBody extends StatelessWidget {
|
||||
))
|
||||
)
|
||||
),
|
||||
new Container(
|
||||
Container(
|
||||
margin: const EdgeInsets.only(right: 8.0),
|
||||
child: new FlatButton(
|
||||
child: FlatButton(
|
||||
onPressed: onSave,
|
||||
textTheme: ButtonTextTheme.accent,
|
||||
child: const Text('SAVE')
|
||||
@@ -148,7 +148,7 @@ class DemoItem<T> {
|
||||
this.hint,
|
||||
this.builder,
|
||||
this.valueToString
|
||||
}) : textController = new TextEditingController(text: valueToString(value));
|
||||
}) : textController = TextEditingController(text: valueToString(value));
|
||||
|
||||
final String name;
|
||||
final String hint;
|
||||
@@ -160,7 +160,7 @@ class DemoItem<T> {
|
||||
|
||||
ExpansionPanelHeaderBuilder get headerBuilder {
|
||||
return (BuildContext context, bool isExpanded) {
|
||||
return new DualHeaderWithHint(
|
||||
return DualHeaderWithHint(
|
||||
name: name,
|
||||
value: valueToString(value),
|
||||
hint: hint,
|
||||
@@ -176,7 +176,7 @@ class ExpansionPanelsDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/expansion_panels';
|
||||
|
||||
@override
|
||||
_ExpansionPanelsDemoState createState() => new _ExpansionPanelsDemoState();
|
||||
_ExpansionPanelsDemoState createState() => _ExpansionPanelsDemoState();
|
||||
}
|
||||
|
||||
class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
|
||||
@@ -187,7 +187,7 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
|
||||
super.initState();
|
||||
|
||||
_demoItems = <DemoItem<dynamic>>[
|
||||
new DemoItem<String>(
|
||||
DemoItem<String>(
|
||||
name: 'Trip',
|
||||
value: 'Caribbean cruise',
|
||||
hint: 'Change trip name',
|
||||
@@ -199,18 +199,18 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
|
||||
});
|
||||
}
|
||||
|
||||
return new Form(
|
||||
child: new Builder(
|
||||
return Form(
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return new CollapsibleBody(
|
||||
return CollapsibleBody(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
onSave: () { Form.of(context).save(); close(); },
|
||||
onCancel: () { Form.of(context).reset(); close(); },
|
||||
child: new Padding(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: new TextFormField(
|
||||
child: TextFormField(
|
||||
controller: item.textController,
|
||||
decoration: new InputDecoration(
|
||||
decoration: InputDecoration(
|
||||
hintText: item.hint,
|
||||
labelText: item.name,
|
||||
),
|
||||
@@ -223,7 +223,7 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
|
||||
);
|
||||
},
|
||||
),
|
||||
new DemoItem<_Location>(
|
||||
DemoItem<_Location>(
|
||||
name: 'Location',
|
||||
value: _Location.Bahamas,
|
||||
hint: 'Select location',
|
||||
@@ -234,24 +234,24 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
|
||||
item.isExpanded = false;
|
||||
});
|
||||
}
|
||||
return new Form(
|
||||
child: new Builder(
|
||||
return Form(
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return new CollapsibleBody(
|
||||
return CollapsibleBody(
|
||||
onSave: () { Form.of(context).save(); close(); },
|
||||
onCancel: () { Form.of(context).reset(); close(); },
|
||||
child: new FormField<_Location>(
|
||||
child: FormField<_Location>(
|
||||
initialValue: item.value,
|
||||
onSaved: (_Location result) { item.value = result; },
|
||||
builder: (FormFieldState<_Location> field) {
|
||||
return new Column(
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Radio<_Location>(
|
||||
Radio<_Location>(
|
||||
value: _Location.Bahamas,
|
||||
groupValue: field.value,
|
||||
onChanged: field.didChange,
|
||||
@@ -259,10 +259,10 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
|
||||
const Text('Bahamas')
|
||||
]
|
||||
),
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Radio<_Location>(
|
||||
Radio<_Location>(
|
||||
value: _Location.Barbados,
|
||||
groupValue: field.value,
|
||||
onChanged: field.didChange,
|
||||
@@ -270,10 +270,10 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
|
||||
const Text('Barbados')
|
||||
]
|
||||
),
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Radio<_Location>(
|
||||
Radio<_Location>(
|
||||
value: _Location.Bermuda,
|
||||
groupValue: field.value,
|
||||
onChanged: field.didChange,
|
||||
@@ -291,7 +291,7 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
|
||||
);
|
||||
}
|
||||
),
|
||||
new DemoItem<double>(
|
||||
DemoItem<double>(
|
||||
name: 'Sun',
|
||||
value: 80.0,
|
||||
hint: 'Select sun level',
|
||||
@@ -303,17 +303,17 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
|
||||
});
|
||||
}
|
||||
|
||||
return new Form(
|
||||
child: new Builder(
|
||||
return Form(
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return new CollapsibleBody(
|
||||
return CollapsibleBody(
|
||||
onSave: () { Form.of(context).save(); close(); },
|
||||
onCancel: () { Form.of(context).reset(); close(); },
|
||||
child: new FormField<double>(
|
||||
child: FormField<double>(
|
||||
initialValue: item.value,
|
||||
onSaved: (double value) { item.value = value; },
|
||||
builder: (FormFieldState<double> field) {
|
||||
return new Slider(
|
||||
return Slider(
|
||||
min: 0.0,
|
||||
max: 100.0,
|
||||
divisions: 5,
|
||||
@@ -335,22 +335,22 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: const Text('Expansion panels')),
|
||||
body: new SingleChildScrollView(
|
||||
child: new SafeArea(
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Expansion panels')),
|
||||
body: SingleChildScrollView(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Container(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(24.0),
|
||||
child: new ExpansionPanelList(
|
||||
child: ExpansionPanelList(
|
||||
expansionCallback: (int index, bool isExpanded) {
|
||||
setState(() {
|
||||
_demoItems[index].isExpanded = !isExpanded;
|
||||
});
|
||||
},
|
||||
children: _demoItems.map((DemoItem<dynamic> item) {
|
||||
return new ExpansionPanel(
|
||||
return ExpansionPanel(
|
||||
isExpanded: item.isExpanded,
|
||||
headerBuilder: item.headerBuilder,
|
||||
body: item.build()
|
||||
|
||||
@@ -19,8 +19,8 @@ enum DismissDialogAction {
|
||||
class DateTimeItem extends StatelessWidget {
|
||||
DateTimeItem({ Key key, DateTime dateTime, @required this.onChanged })
|
||||
: assert(onChanged != null),
|
||||
date = new DateTime(dateTime.year, dateTime.month, dateTime.day),
|
||||
time = new TimeOfDay(hour: dateTime.hour, minute: dateTime.minute),
|
||||
date = DateTime(dateTime.year, dateTime.month, dateTime.day),
|
||||
time = TimeOfDay(hour: dateTime.hour, minute: dateTime.minute),
|
||||
super(key: key);
|
||||
|
||||
final DateTime date;
|
||||
@@ -31,17 +31,17 @@ class DateTimeItem extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
|
||||
return new DefaultTextStyle(
|
||||
return DefaultTextStyle(
|
||||
style: theme.textTheme.subhead,
|
||||
child: new Row(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
child: new Container(
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border(bottom: new BorderSide(color: theme.dividerColor))
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: theme.dividerColor))
|
||||
),
|
||||
child: new InkWell(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
showDatePicker(
|
||||
context: context,
|
||||
@@ -51,26 +51,26 @@ class DateTimeItem extends StatelessWidget {
|
||||
)
|
||||
.then<Null>((DateTime value) {
|
||||
if (value != null)
|
||||
onChanged(new DateTime(value.year, value.month, value.day, time.hour, time.minute));
|
||||
onChanged(DateTime(value.year, value.month, value.day, time.hour, time.minute));
|
||||
});
|
||||
},
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
new Text(new DateFormat('EEE, MMM d yyyy').format(date)),
|
||||
Text(DateFormat('EEE, MMM d yyyy').format(date)),
|
||||
const Icon(Icons.arrow_drop_down, color: Colors.black54),
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
new Container(
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 8.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border(bottom: new BorderSide(color: theme.dividerColor))
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: theme.dividerColor))
|
||||
),
|
||||
child: new InkWell(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
showTimePicker(
|
||||
context: context,
|
||||
@@ -78,12 +78,12 @@ class DateTimeItem extends StatelessWidget {
|
||||
)
|
||||
.then<Null>((TimeOfDay value) {
|
||||
if (value != null)
|
||||
onChanged(new DateTime(date.year, date.month, date.day, value.hour, value.minute));
|
||||
onChanged(DateTime(date.year, date.month, date.day, value.hour, value.minute));
|
||||
});
|
||||
},
|
||||
child: new Row(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Text('${time.format(context)}'),
|
||||
Text('${time.format(context)}'),
|
||||
const Icon(Icons.arrow_drop_down, color: Colors.black54),
|
||||
]
|
||||
)
|
||||
@@ -97,12 +97,12 @@ class DateTimeItem extends StatelessWidget {
|
||||
|
||||
class FullScreenDialogDemo extends StatefulWidget {
|
||||
@override
|
||||
FullScreenDialogDemoState createState() => new FullScreenDialogDemoState();
|
||||
FullScreenDialogDemoState createState() => FullScreenDialogDemoState();
|
||||
}
|
||||
|
||||
class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
|
||||
DateTime _fromDateTime = new DateTime.now();
|
||||
DateTime _toDateTime = new DateTime.now();
|
||||
DateTime _fromDateTime = DateTime.now();
|
||||
DateTime _toDateTime = DateTime.now();
|
||||
bool _allDayValue = false;
|
||||
bool _saveNeeded = false;
|
||||
bool _hasLocation = false;
|
||||
@@ -120,19 +120,19 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
|
||||
return await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return new AlertDialog(
|
||||
content: new Text(
|
||||
return AlertDialog(
|
||||
content: Text(
|
||||
'Discard new event?',
|
||||
style: dialogTextStyle
|
||||
),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('CANCEL'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(false); // Pops the confirmation dialog but not the page.
|
||||
}
|
||||
),
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('DISCARD'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(true); // Returning true to _onWillPop will pop again.
|
||||
@@ -148,27 +148,27 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text(_hasName ? _eventName : 'Event Name TBD'),
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(_hasName ? _eventName : 'Event Name TBD'),
|
||||
actions: <Widget> [
|
||||
new FlatButton(
|
||||
child: new Text('SAVE', style: theme.textTheme.body1.copyWith(color: Colors.white)),
|
||||
FlatButton(
|
||||
child: Text('SAVE', style: theme.textTheme.body1.copyWith(color: Colors.white)),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, DismissDialogAction.save);
|
||||
}
|
||||
)
|
||||
]
|
||||
),
|
||||
body: new Form(
|
||||
body: Form(
|
||||
onWillPop: _onWillPop,
|
||||
child: new ListView(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: new TextField(
|
||||
child: TextField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Event name',
|
||||
filled: true
|
||||
@@ -184,10 +184,10 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
|
||||
}
|
||||
)
|
||||
),
|
||||
new Container(
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: new TextField(
|
||||
child: TextField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Location',
|
||||
hintText: 'Where is the event?',
|
||||
@@ -200,11 +200,11 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
|
||||
}
|
||||
)
|
||||
),
|
||||
new Column(
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Text('From', style: theme.textTheme.caption),
|
||||
new DateTimeItem(
|
||||
Text('From', style: theme.textTheme.caption),
|
||||
DateTimeItem(
|
||||
dateTime: _fromDateTime,
|
||||
onChanged: (DateTime value) {
|
||||
setState(() {
|
||||
@@ -215,11 +215,11 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
|
||||
)
|
||||
]
|
||||
),
|
||||
new Column(
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Text('To', style: theme.textTheme.caption),
|
||||
new DateTimeItem(
|
||||
Text('To', style: theme.textTheme.caption),
|
||||
DateTimeItem(
|
||||
dateTime: _toDateTime,
|
||||
onChanged: (DateTime value) {
|
||||
setState(() {
|
||||
@@ -231,13 +231,13 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
|
||||
const Text('All-day'),
|
||||
]
|
||||
),
|
||||
new Container(
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border(bottom: new BorderSide(color: theme.dividerColor))
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: theme.dividerColor))
|
||||
),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
children: <Widget> [
|
||||
new Checkbox(
|
||||
Checkbox(
|
||||
value: _allDayValue,
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
@@ -252,7 +252,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
|
||||
)
|
||||
]
|
||||
.map((Widget child) {
|
||||
return new Container(
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
height: 96.0,
|
||||
child: child
|
||||
|
||||
@@ -41,7 +41,7 @@ class GridPhotoViewer extends StatefulWidget {
|
||||
final Photo photo;
|
||||
|
||||
@override
|
||||
_GridPhotoViewerState createState() => new _GridPhotoViewerState();
|
||||
_GridPhotoViewerState createState() => _GridPhotoViewerState();
|
||||
}
|
||||
|
||||
class _GridTitleText extends StatelessWidget {
|
||||
@@ -51,10 +51,10 @@ class _GridTitleText extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new FittedBox(
|
||||
return FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: Alignment.centerLeft,
|
||||
child: new Text(text),
|
||||
child: Text(text),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = new AnimationController(vsync: this)
|
||||
_controller = AnimationController(vsync: this)
|
||||
..addListener(_handleFlingAnimation);
|
||||
}
|
||||
|
||||
@@ -84,8 +84,8 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
|
||||
// then the minimum offset value is w - _scale * w, h - _scale * h.
|
||||
Offset _clampOffset(Offset offset) {
|
||||
final Size size = context.size;
|
||||
final Offset minOffset = new Offset(size.width, size.height) * (1.0 - _scale);
|
||||
return new Offset(offset.dx.clamp(minOffset.dx, 0.0), offset.dy.clamp(minOffset.dy, 0.0));
|
||||
final Offset minOffset = Offset(size.width, size.height) * (1.0 - _scale);
|
||||
return Offset(offset.dx.clamp(minOffset.dx, 0.0), offset.dy.clamp(minOffset.dy, 0.0));
|
||||
}
|
||||
|
||||
void _handleFlingAnimation() {
|
||||
@@ -117,7 +117,7 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
|
||||
return;
|
||||
final Offset direction = details.velocity.pixelsPerSecond / magnitude;
|
||||
final double distance = (Offset.zero & context.size).shortestSide;
|
||||
_flingAnimation = new Tween<Offset>(
|
||||
_flingAnimation = Tween<Offset>(
|
||||
begin: _offset,
|
||||
end: _clampOffset(_offset + direction * distance)
|
||||
).animate(_controller);
|
||||
@@ -128,16 +128,16 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new GestureDetector(
|
||||
return GestureDetector(
|
||||
onScaleStart: _handleOnScaleStart,
|
||||
onScaleUpdate: _handleOnScaleUpdate,
|
||||
onScaleEnd: _handleOnScaleEnd,
|
||||
child: new ClipRect(
|
||||
child: new Transform(
|
||||
transform: new Matrix4.identity()
|
||||
child: ClipRect(
|
||||
child: Transform(
|
||||
transform: Matrix4.identity()
|
||||
..translate(_offset.dx, _offset.dy)
|
||||
..scale(_scale),
|
||||
child: new Image.asset(
|
||||
child: Image.asset(
|
||||
widget.photo.assetName,
|
||||
package: widget.photo.assetPackage,
|
||||
fit: BoxFit.cover,
|
||||
@@ -164,16 +164,16 @@ class GridDemoPhotoItem extends StatelessWidget {
|
||||
final BannerTapCallback onBannerTap; // User taps on the photo's header or footer.
|
||||
|
||||
void showPhoto(BuildContext context) {
|
||||
Navigator.push(context, new MaterialPageRoute<void>(
|
||||
Navigator.push(context, MaterialPageRoute<void>(
|
||||
builder: (BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text(photo.title)
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(photo.title)
|
||||
),
|
||||
body: new SizedBox.expand(
|
||||
child: new Hero(
|
||||
body: SizedBox.expand(
|
||||
child: Hero(
|
||||
tag: photo.tag,
|
||||
child: new GridPhotoViewer(photo: photo),
|
||||
child: GridPhotoViewer(photo: photo),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -183,12 +183,12 @@ class GridDemoPhotoItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Widget image = new GestureDetector(
|
||||
final Widget image = GestureDetector(
|
||||
onTap: () { showPhoto(context); },
|
||||
child: new Hero(
|
||||
key: new Key(photo.assetName),
|
||||
child: Hero(
|
||||
key: Key(photo.assetName),
|
||||
tag: photo.tag,
|
||||
child: new Image.asset(
|
||||
child: Image.asset(
|
||||
photo.assetName,
|
||||
package: photo.assetPackage,
|
||||
fit: BoxFit.cover,
|
||||
@@ -203,13 +203,13 @@ class GridDemoPhotoItem extends StatelessWidget {
|
||||
return image;
|
||||
|
||||
case GridDemoTileStyle.oneLine:
|
||||
return new GridTile(
|
||||
header: new GestureDetector(
|
||||
return GridTile(
|
||||
header: GestureDetector(
|
||||
onTap: () { onBannerTap(photo); },
|
||||
child: new GridTileBar(
|
||||
title: new _GridTitleText(photo.title),
|
||||
child: GridTileBar(
|
||||
title: _GridTitleText(photo.title),
|
||||
backgroundColor: Colors.black45,
|
||||
leading: new Icon(
|
||||
leading: Icon(
|
||||
icon,
|
||||
color: Colors.white,
|
||||
),
|
||||
@@ -219,14 +219,14 @@ class GridDemoPhotoItem extends StatelessWidget {
|
||||
);
|
||||
|
||||
case GridDemoTileStyle.twoLine:
|
||||
return new GridTile(
|
||||
footer: new GestureDetector(
|
||||
return GridTile(
|
||||
footer: GestureDetector(
|
||||
onTap: () { onBannerTap(photo); },
|
||||
child: new GridTileBar(
|
||||
child: GridTileBar(
|
||||
backgroundColor: Colors.black45,
|
||||
title: new _GridTitleText(photo.title),
|
||||
subtitle: new _GridTitleText(photo.caption),
|
||||
trailing: new Icon(
|
||||
title: _GridTitleText(photo.title),
|
||||
subtitle: _GridTitleText(photo.caption),
|
||||
trailing: Icon(
|
||||
icon,
|
||||
color: Colors.white,
|
||||
),
|
||||
@@ -246,80 +246,80 @@ class GridListDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/grid-list';
|
||||
|
||||
@override
|
||||
GridListDemoState createState() => new GridListDemoState();
|
||||
GridListDemoState createState() => GridListDemoState();
|
||||
}
|
||||
|
||||
class GridListDemoState extends State<GridListDemo> {
|
||||
GridDemoTileStyle _tileStyle = GridDemoTileStyle.twoLine;
|
||||
|
||||
List<Photo> photos = <Photo>[
|
||||
new Photo(
|
||||
Photo(
|
||||
assetName: 'places/india_chennai_flower_market.png',
|
||||
assetPackage: _kGalleryAssetsPackage,
|
||||
title: 'Chennai',
|
||||
caption: 'Flower Market',
|
||||
),
|
||||
new Photo(
|
||||
Photo(
|
||||
assetName: 'places/india_tanjore_bronze_works.png',
|
||||
assetPackage: _kGalleryAssetsPackage,
|
||||
title: 'Tanjore',
|
||||
caption: 'Bronze Works',
|
||||
),
|
||||
new Photo(
|
||||
Photo(
|
||||
assetName: 'places/india_tanjore_market_merchant.png',
|
||||
assetPackage: _kGalleryAssetsPackage,
|
||||
title: 'Tanjore',
|
||||
caption: 'Market',
|
||||
),
|
||||
new Photo(
|
||||
Photo(
|
||||
assetName: 'places/india_tanjore_thanjavur_temple.png',
|
||||
assetPackage: _kGalleryAssetsPackage,
|
||||
title: 'Tanjore',
|
||||
caption: 'Thanjavur Temple',
|
||||
),
|
||||
new Photo(
|
||||
Photo(
|
||||
assetName: 'places/india_tanjore_thanjavur_temple_carvings.png',
|
||||
assetPackage: _kGalleryAssetsPackage,
|
||||
title: 'Tanjore',
|
||||
caption: 'Thanjavur Temple',
|
||||
),
|
||||
new Photo(
|
||||
Photo(
|
||||
assetName: 'places/india_pondicherry_salt_farm.png',
|
||||
assetPackage: _kGalleryAssetsPackage,
|
||||
title: 'Pondicherry',
|
||||
caption: 'Salt Farm',
|
||||
),
|
||||
new Photo(
|
||||
Photo(
|
||||
assetName: 'places/india_chennai_highway.png',
|
||||
assetPackage: _kGalleryAssetsPackage,
|
||||
title: 'Chennai',
|
||||
caption: 'Scooters',
|
||||
),
|
||||
new Photo(
|
||||
Photo(
|
||||
assetName: 'places/india_chettinad_silk_maker.png',
|
||||
assetPackage: _kGalleryAssetsPackage,
|
||||
title: 'Chettinad',
|
||||
caption: 'Silk Maker',
|
||||
),
|
||||
new Photo(
|
||||
Photo(
|
||||
assetName: 'places/india_chettinad_produce.png',
|
||||
assetPackage: _kGalleryAssetsPackage,
|
||||
title: 'Chettinad',
|
||||
caption: 'Lunch Prep',
|
||||
),
|
||||
new Photo(
|
||||
Photo(
|
||||
assetName: 'places/india_tanjore_market_technology.png',
|
||||
assetPackage: _kGalleryAssetsPackage,
|
||||
title: 'Tanjore',
|
||||
caption: 'Market',
|
||||
),
|
||||
new Photo(
|
||||
Photo(
|
||||
assetName: 'places/india_pondicherry_beach.png',
|
||||
assetPackage: _kGalleryAssetsPackage,
|
||||
title: 'Pondicherry',
|
||||
caption: 'Beach',
|
||||
),
|
||||
new Photo(
|
||||
Photo(
|
||||
assetName: 'places/india_pondicherry_fisherman.png',
|
||||
assetPackage: _kGalleryAssetsPackage,
|
||||
title: 'Pondicherry',
|
||||
@@ -336,11 +336,11 @@ class GridListDemoState extends State<GridListDemo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Orientation orientation = MediaQuery.of(context).orientation;
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Grid list'),
|
||||
actions: <Widget>[
|
||||
new PopupMenuButton<GridDemoTileStyle>(
|
||||
PopupMenuButton<GridDemoTileStyle>(
|
||||
onSelected: changeTileStyle,
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<GridDemoTileStyle>>[
|
||||
const PopupMenuItem<GridDemoTileStyle>(
|
||||
@@ -359,20 +359,20 @@ class GridListDemoState extends State<GridListDemo> {
|
||||
),
|
||||
],
|
||||
),
|
||||
body: new Column(
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
child: new SafeArea(
|
||||
Expanded(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new GridView.count(
|
||||
child: GridView.count(
|
||||
crossAxisCount: (orientation == Orientation.portrait) ? 2 : 3,
|
||||
mainAxisSpacing: 4.0,
|
||||
crossAxisSpacing: 4.0,
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
childAspectRatio: (orientation == Orientation.portrait) ? 1.0 : 1.3,
|
||||
children: photos.map((Photo photo) {
|
||||
return new GridDemoPhotoItem(
|
||||
return GridDemoPhotoItem(
|
||||
photo: photo,
|
||||
tileStyle: _tileStyle,
|
||||
onBannerTap: (Photo photo) {
|
||||
|
||||
@@ -8,7 +8,7 @@ class IconsDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/icons';
|
||||
|
||||
@override
|
||||
IconsDemoState createState() => new IconsDemoState();
|
||||
IconsDemoState createState() => IconsDemoState();
|
||||
}
|
||||
|
||||
class IconsDemoState extends State<IconsDemo> {
|
||||
@@ -46,21 +46,21 @@ class IconsDemoState extends State<IconsDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Icons')
|
||||
),
|
||||
body: new IconTheme(
|
||||
data: new IconThemeData(color: iconColor),
|
||||
child: new SafeArea(
|
||||
body: IconTheme(
|
||||
data: IconThemeData(color: iconColor),
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new ListView(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
children: <Widget>[
|
||||
new _IconsDemoCard(handleIconButtonPress, Icons.face), // direction-agnostic icon
|
||||
_IconsDemoCard(handleIconButtonPress, Icons.face), // direction-agnostic icon
|
||||
const SizedBox(height: 24.0),
|
||||
new _IconsDemoCard(handleIconButtonPress, Icons.battery_unknown), // direction-aware icon
|
||||
_IconsDemoCard(handleIconButtonPress, Icons.battery_unknown), // direction-aware icon
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -76,8 +76,8 @@ class _IconsDemoCard extends StatelessWidget {
|
||||
final IconData icon;
|
||||
|
||||
Widget _buildIconButton(double iconSize, IconData icon, bool enabled) {
|
||||
return new IconButton(
|
||||
icon: new Icon(icon),
|
||||
return IconButton(
|
||||
icon: Icon(icon),
|
||||
iconSize: iconSize,
|
||||
tooltip: "${enabled ? 'Enabled' : 'Disabled'} icon button",
|
||||
onPressed: enabled ? handleIconButtonPress : null
|
||||
@@ -85,14 +85,14 @@ class _IconsDemoCard extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _centeredText(String label) =>
|
||||
new Padding(
|
||||
Padding(
|
||||
// Match the default padding of IconButton.
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Text(label, textAlign: TextAlign.center),
|
||||
child: Text(label, textAlign: TextAlign.center),
|
||||
);
|
||||
|
||||
TableRow _buildIconRow(double size) {
|
||||
return new TableRow(
|
||||
return TableRow(
|
||||
children: <Widget> [
|
||||
_centeredText(size.floor().toString()),
|
||||
_buildIconButton(size, icon, true),
|
||||
@@ -105,15 +105,15 @@ class _IconsDemoCard extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final TextStyle textStyle = theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color);
|
||||
return new Card(
|
||||
child: new DefaultTextStyle(
|
||||
return Card(
|
||||
child: DefaultTextStyle(
|
||||
style: textStyle,
|
||||
child: new Semantics(
|
||||
child: Semantics(
|
||||
explicitChildNodes: true,
|
||||
child: new Table(
|
||||
child: Table(
|
||||
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
|
||||
children: <TableRow> [
|
||||
new TableRow(
|
||||
TableRow(
|
||||
children: <Widget> [
|
||||
_centeredText('Size'),
|
||||
_centeredText('Enabled'),
|
||||
|
||||
@@ -35,17 +35,17 @@ class LeaveBehindDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/leave-behind';
|
||||
|
||||
@override
|
||||
LeaveBehindDemoState createState() => new LeaveBehindDemoState();
|
||||
LeaveBehindDemoState createState() => LeaveBehindDemoState();
|
||||
}
|
||||
|
||||
class LeaveBehindDemoState extends State<LeaveBehindDemo> {
|
||||
static final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
static final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
DismissDirection _dismissDirection = DismissDirection.horizontal;
|
||||
List<LeaveBehindItem> leaveBehindItems;
|
||||
|
||||
void initListItems() {
|
||||
leaveBehindItems = new List<LeaveBehindItem>.generate(16, (int index) {
|
||||
return new LeaveBehindItem(
|
||||
leaveBehindItems = List<LeaveBehindItem>.generate(16, (int index) {
|
||||
return LeaveBehindItem(
|
||||
index: index,
|
||||
name: 'Item $index Sender',
|
||||
subject: 'Subject: $index',
|
||||
@@ -90,9 +90,9 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
|
||||
setState(() {
|
||||
leaveBehindItems.remove(item);
|
||||
});
|
||||
_scaffoldKey.currentState.showSnackBar(new SnackBar(
|
||||
content: new Text('You archived item ${item.index}'),
|
||||
action: new SnackBarAction(
|
||||
_scaffoldKey.currentState.showSnackBar(SnackBar(
|
||||
content: Text('You archived item ${item.index}'),
|
||||
action: SnackBarAction(
|
||||
label: 'UNDO',
|
||||
onPressed: () { handleUndo(item); }
|
||||
)
|
||||
@@ -103,9 +103,9 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
|
||||
setState(() {
|
||||
leaveBehindItems.remove(item);
|
||||
});
|
||||
_scaffoldKey.currentState.showSnackBar(new SnackBar(
|
||||
content: new Text('You deleted item ${item.index}'),
|
||||
action: new SnackBarAction(
|
||||
_scaffoldKey.currentState.showSnackBar(SnackBar(
|
||||
content: Text('You deleted item ${item.index}'),
|
||||
action: SnackBarAction(
|
||||
label: 'UNDO',
|
||||
onPressed: () { handleUndo(item); }
|
||||
)
|
||||
@@ -116,16 +116,16 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
|
||||
Widget build(BuildContext context) {
|
||||
Widget body;
|
||||
if (leaveBehindItems.isEmpty) {
|
||||
body = new Center(
|
||||
child: new RaisedButton(
|
||||
body = Center(
|
||||
child: RaisedButton(
|
||||
onPressed: () => handleDemoAction(LeaveBehindDemoAction.reset),
|
||||
child: const Text('Reset the list'),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
body = new ListView(
|
||||
body = ListView(
|
||||
children: leaveBehindItems.map((LeaveBehindItem item) {
|
||||
return new _LeaveBehindListItem(
|
||||
return _LeaveBehindListItem(
|
||||
item: item,
|
||||
onArchive: _handleArchive,
|
||||
onDelete: _handleDelete,
|
||||
@@ -135,12 +135,12 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
|
||||
);
|
||||
}
|
||||
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: new AppBar(
|
||||
appBar: AppBar(
|
||||
title: const Text('Swipe to dismiss'),
|
||||
actions: <Widget>[
|
||||
new PopupMenuButton<LeaveBehindDemoAction>(
|
||||
PopupMenuButton<LeaveBehindDemoAction>(
|
||||
onSelected: handleDemoAction,
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<LeaveBehindDemoAction>>[
|
||||
const PopupMenuItem<LeaveBehindDemoAction>(
|
||||
@@ -148,17 +148,17 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
|
||||
child: Text('Reset the list')
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
new CheckedPopupMenuItem<LeaveBehindDemoAction>(
|
||||
CheckedPopupMenuItem<LeaveBehindDemoAction>(
|
||||
value: LeaveBehindDemoAction.horizontalSwipe,
|
||||
checked: _dismissDirection == DismissDirection.horizontal,
|
||||
child: const Text('Horizontal swipe')
|
||||
),
|
||||
new CheckedPopupMenuItem<LeaveBehindDemoAction>(
|
||||
CheckedPopupMenuItem<LeaveBehindDemoAction>(
|
||||
value: LeaveBehindDemoAction.leftSwipe,
|
||||
checked: _dismissDirection == DismissDirection.endToStart,
|
||||
child: const Text('Only swipe left')
|
||||
),
|
||||
new CheckedPopupMenuItem<LeaveBehindDemoAction>(
|
||||
CheckedPopupMenuItem<LeaveBehindDemoAction>(
|
||||
value: LeaveBehindDemoAction.rightSwipe,
|
||||
checked: _dismissDirection == DismissDirection.startToEnd,
|
||||
child: const Text('Only swipe right')
|
||||
@@ -197,13 +197,13 @@ class _LeaveBehindListItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return new Semantics(
|
||||
return Semantics(
|
||||
customSemanticsActions: <CustomSemanticsAction, VoidCallback>{
|
||||
const CustomSemanticsAction(label: 'Archive'): _handleArchive,
|
||||
const CustomSemanticsAction(label: 'Delete'): _handleDelete,
|
||||
},
|
||||
child: new Dismissible(
|
||||
key: new ObjectKey(item),
|
||||
child: Dismissible(
|
||||
key: ObjectKey(item),
|
||||
direction: dismissDirection,
|
||||
onDismissed: (DismissDirection direction) {
|
||||
if (direction == DismissDirection.endToStart)
|
||||
@@ -211,26 +211,26 @@ class _LeaveBehindListItem extends StatelessWidget {
|
||||
else
|
||||
_handleDelete();
|
||||
},
|
||||
background: new Container(
|
||||
background: Container(
|
||||
color: theme.primaryColor,
|
||||
child: const ListTile(
|
||||
leading: Icon(Icons.delete, color: Colors.white, size: 36.0)
|
||||
)
|
||||
),
|
||||
secondaryBackground: new Container(
|
||||
secondaryBackground: Container(
|
||||
color: theme.primaryColor,
|
||||
child: const ListTile(
|
||||
trailing: Icon(Icons.archive, color: Colors.white, size: 36.0)
|
||||
)
|
||||
),
|
||||
child: new Container(
|
||||
decoration: new BoxDecoration(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.canvasColor,
|
||||
border: new Border(bottom: new BorderSide(color: theme.dividerColor))
|
||||
border: Border(bottom: BorderSide(color: theme.dividerColor))
|
||||
),
|
||||
child: new ListTile(
|
||||
title: new Text(item.name),
|
||||
subtitle: new Text('${item.subject}\n${item.body}'),
|
||||
child: ListTile(
|
||||
title: Text(item.name),
|
||||
subtitle: Text('${item.subject}\n${item.body}'),
|
||||
isThreeLine: true
|
||||
),
|
||||
),
|
||||
|
||||
@@ -24,11 +24,11 @@ class ListDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/list';
|
||||
|
||||
@override
|
||||
_ListDemoState createState() => new _ListDemoState();
|
||||
_ListDemoState createState() => _ListDemoState();
|
||||
}
|
||||
|
||||
class _ListDemoState extends State<ListDemo> {
|
||||
static final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
PersistentBottomSheetController<Null> _bottomSheet;
|
||||
_MaterialListType _itemType = _MaterialListType.threeLine;
|
||||
@@ -50,52 +50,52 @@ class _ListDemoState extends State<ListDemo> {
|
||||
|
||||
void _showConfigurationSheet() {
|
||||
final PersistentBottomSheetController<Null> bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) {
|
||||
return new Container(
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(top: BorderSide(color: Colors.black26)),
|
||||
),
|
||||
child: new ListView(
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
primary: false,
|
||||
children: <Widget>[
|
||||
new MergeSemantics(
|
||||
child: new ListTile(
|
||||
MergeSemantics(
|
||||
child: ListTile(
|
||||
dense: true,
|
||||
title: const Text('One-line'),
|
||||
trailing: new Radio<_MaterialListType>(
|
||||
trailing: Radio<_MaterialListType>(
|
||||
value: _showAvatars ? _MaterialListType.oneLineWithAvatar : _MaterialListType.oneLine,
|
||||
groupValue: _itemType,
|
||||
onChanged: changeItemType,
|
||||
)
|
||||
),
|
||||
),
|
||||
new MergeSemantics(
|
||||
child: new ListTile(
|
||||
MergeSemantics(
|
||||
child: ListTile(
|
||||
dense: true,
|
||||
title: const Text('Two-line'),
|
||||
trailing: new Radio<_MaterialListType>(
|
||||
trailing: Radio<_MaterialListType>(
|
||||
value: _MaterialListType.twoLine,
|
||||
groupValue: _itemType,
|
||||
onChanged: changeItemType,
|
||||
)
|
||||
),
|
||||
),
|
||||
new MergeSemantics(
|
||||
child: new ListTile(
|
||||
MergeSemantics(
|
||||
child: ListTile(
|
||||
dense: true,
|
||||
title: const Text('Three-line'),
|
||||
trailing: new Radio<_MaterialListType>(
|
||||
trailing: Radio<_MaterialListType>(
|
||||
value: _MaterialListType.threeLine,
|
||||
groupValue: _itemType,
|
||||
onChanged: changeItemType,
|
||||
),
|
||||
),
|
||||
),
|
||||
new MergeSemantics(
|
||||
child: new ListTile(
|
||||
MergeSemantics(
|
||||
child: ListTile(
|
||||
dense: true,
|
||||
title: const Text('Show avatar'),
|
||||
trailing: new Checkbox(
|
||||
trailing: Checkbox(
|
||||
value: _showAvatars,
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
@@ -106,11 +106,11 @@ class _ListDemoState extends State<ListDemo> {
|
||||
),
|
||||
),
|
||||
),
|
||||
new MergeSemantics(
|
||||
child: new ListTile(
|
||||
MergeSemantics(
|
||||
child: ListTile(
|
||||
dense: true,
|
||||
title: const Text('Show icon'),
|
||||
trailing: new Checkbox(
|
||||
trailing: Checkbox(
|
||||
value: _showIcons,
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
@@ -121,11 +121,11 @@ class _ListDemoState extends State<ListDemo> {
|
||||
),
|
||||
),
|
||||
),
|
||||
new MergeSemantics(
|
||||
child: new ListTile(
|
||||
MergeSemantics(
|
||||
child: ListTile(
|
||||
dense: true,
|
||||
title: const Text('Show dividers'),
|
||||
trailing: new Checkbox(
|
||||
trailing: Checkbox(
|
||||
value: _showDividers,
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
@@ -136,11 +136,11 @@ class _ListDemoState extends State<ListDemo> {
|
||||
),
|
||||
),
|
||||
),
|
||||
new MergeSemantics(
|
||||
child: new ListTile(
|
||||
MergeSemantics(
|
||||
child: ListTile(
|
||||
dense: true,
|
||||
title: const Text('Dense layout'),
|
||||
trailing: new Checkbox(
|
||||
trailing: Checkbox(
|
||||
value: _dense,
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
@@ -178,14 +178,14 @@ class _ListDemoState extends State<ListDemo> {
|
||||
'Even more additional list item information appears on line three.',
|
||||
);
|
||||
}
|
||||
return new MergeSemantics(
|
||||
child: new ListTile(
|
||||
return MergeSemantics(
|
||||
child: ListTile(
|
||||
isThreeLine: _itemType == _MaterialListType.threeLine,
|
||||
dense: _dense,
|
||||
leading: _showAvatars ? new ExcludeSemantics(child: new CircleAvatar(child: new Text(item))) : null,
|
||||
title: new Text('This item represents $item.'),
|
||||
leading: _showAvatars ? ExcludeSemantics(child: CircleAvatar(child: Text(item))) : null,
|
||||
title: Text('This item represents $item.'),
|
||||
subtitle: secondary,
|
||||
trailing: _showIcons ? new Icon(Icons.info, color: Theme.of(context).disabledColor) : null,
|
||||
trailing: _showIcons ? Icon(Icons.info, color: Theme.of(context).disabledColor) : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -211,12 +211,12 @@ class _ListDemoState extends State<ListDemo> {
|
||||
if (_showDividers)
|
||||
listTiles = ListTile.divideTiles(context: context, tiles: listTiles);
|
||||
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: scaffoldKey,
|
||||
appBar: new AppBar(
|
||||
title: new Text('Scrolling list\n$itemTypeText$layoutText'),
|
||||
appBar: AppBar(
|
||||
title: Text('Scrolling list\n$itemTypeText$layoutText'),
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.sort_by_alpha),
|
||||
tooltip: 'Sort',
|
||||
onPressed: () {
|
||||
@@ -226,8 +226,8 @@ class _ListDemoState extends State<ListDemo> {
|
||||
});
|
||||
},
|
||||
),
|
||||
new IconButton(
|
||||
icon: new Icon(
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Theme.of(context).platform == TargetPlatform.iOS
|
||||
? Icons.more_horiz
|
||||
: Icons.more_vert,
|
||||
@@ -237,9 +237,9 @@ class _ListDemoState extends State<ListDemo> {
|
||||
),
|
||||
],
|
||||
),
|
||||
body: new Scrollbar(
|
||||
child: new ListView(
|
||||
padding: new EdgeInsets.symmetric(vertical: _dense ? 4.0 : 8.0),
|
||||
body: Scrollbar(
|
||||
child: ListView(
|
||||
padding: EdgeInsets.symmetric(vertical: _dense ? 4.0 : 8.0),
|
||||
children: listTiles.toList(),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -10,11 +10,11 @@ class MenuDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/menu';
|
||||
|
||||
@override
|
||||
MenuDemoState createState() => new MenuDemoState();
|
||||
MenuDemoState createState() => MenuDemoState();
|
||||
}
|
||||
|
||||
class MenuDemoState extends State<MenuDemo> {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
final String _simpleValue1 = 'Menu item value one';
|
||||
final String _simpleValue2 = 'Menu item value two';
|
||||
@@ -35,8 +35,8 @@ class MenuDemoState extends State<MenuDemo> {
|
||||
}
|
||||
|
||||
void showInSnackBar(String value) {
|
||||
_scaffoldKey.currentState.showSnackBar(new SnackBar(
|
||||
content: new Text(value)
|
||||
_scaffoldKey.currentState.showSnackBar(SnackBar(
|
||||
content: Text(value)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -59,12 +59,12 @@ class MenuDemoState extends State<MenuDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: new AppBar(
|
||||
appBar: AppBar(
|
||||
title: const Text('Menus'),
|
||||
actions: <Widget>[
|
||||
new PopupMenuButton<String>(
|
||||
PopupMenuButton<String>(
|
||||
onSelected: showMenuSelection,
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
|
||||
const PopupMenuItem<String>(
|
||||
@@ -83,19 +83,19 @@ class MenuDemoState extends State<MenuDemo> {
|
||||
),
|
||||
],
|
||||
),
|
||||
body: new ListView(
|
||||
body: ListView(
|
||||
padding: kMaterialListPadding,
|
||||
children: <Widget>[
|
||||
// Pressing the PopupMenuButton on the right of this item shows
|
||||
// a simple menu with one disabled item. Typically the contents
|
||||
// of this "contextual menu" would reflect the app's state.
|
||||
new ListTile(
|
||||
ListTile(
|
||||
title: const Text('An item with a context menu button'),
|
||||
trailing: new PopupMenuButton<String>(
|
||||
trailing: PopupMenuButton<String>(
|
||||
padding: EdgeInsets.zero,
|
||||
onSelected: showMenuSelection,
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
|
||||
new PopupMenuItem<String>(
|
||||
PopupMenuItem<String>(
|
||||
value: _simpleValue1,
|
||||
child: const Text('Context menu item one')
|
||||
),
|
||||
@@ -103,7 +103,7 @@ class MenuDemoState extends State<MenuDemo> {
|
||||
enabled: false,
|
||||
child: Text('A disabled menu item')
|
||||
),
|
||||
new PopupMenuItem<String>(
|
||||
PopupMenuItem<String>(
|
||||
value: _simpleValue3,
|
||||
child: const Text('Context menu item three')
|
||||
),
|
||||
@@ -113,9 +113,9 @@ class MenuDemoState extends State<MenuDemo> {
|
||||
// Pressing the PopupMenuButton on the right of this item shows
|
||||
// a menu whose items have text labels and icons and a divider
|
||||
// That separates the first three items from the last one.
|
||||
new ListTile(
|
||||
ListTile(
|
||||
title: const Text('An item with a sectioned menu'),
|
||||
trailing: new PopupMenuButton<String>(
|
||||
trailing: PopupMenuButton<String>(
|
||||
padding: EdgeInsets.zero,
|
||||
onSelected: showMenuSelection,
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
|
||||
@@ -154,57 +154,57 @@ class MenuDemoState extends State<MenuDemo> {
|
||||
// This entire list item is a PopupMenuButton. Tapping anywhere shows
|
||||
// a menu whose current value is highlighted and aligned over the
|
||||
// list item's center line.
|
||||
new PopupMenuButton<String>(
|
||||
PopupMenuButton<String>(
|
||||
padding: EdgeInsets.zero,
|
||||
initialValue: _simpleValue,
|
||||
onSelected: showMenuSelection,
|
||||
child: new ListTile(
|
||||
child: ListTile(
|
||||
title: const Text('An item with a simple menu'),
|
||||
subtitle: new Text(_simpleValue)
|
||||
subtitle: Text(_simpleValue)
|
||||
),
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
|
||||
new PopupMenuItem<String>(
|
||||
PopupMenuItem<String>(
|
||||
value: _simpleValue1,
|
||||
child: new Text(_simpleValue1)
|
||||
child: Text(_simpleValue1)
|
||||
),
|
||||
new PopupMenuItem<String>(
|
||||
PopupMenuItem<String>(
|
||||
value: _simpleValue2,
|
||||
child: new Text(_simpleValue2)
|
||||
child: Text(_simpleValue2)
|
||||
),
|
||||
new PopupMenuItem<String>(
|
||||
PopupMenuItem<String>(
|
||||
value: _simpleValue3,
|
||||
child: new Text(_simpleValue3)
|
||||
child: Text(_simpleValue3)
|
||||
)
|
||||
]
|
||||
),
|
||||
// Pressing the PopupMenuButton on the right of this item shows a menu
|
||||
// whose items have checked icons that reflect this app's state.
|
||||
new ListTile(
|
||||
ListTile(
|
||||
title: const Text('An item with a checklist menu'),
|
||||
trailing: new PopupMenuButton<String>(
|
||||
trailing: PopupMenuButton<String>(
|
||||
padding: EdgeInsets.zero,
|
||||
onSelected: showCheckedMenuSelections,
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
|
||||
new CheckedPopupMenuItem<String>(
|
||||
CheckedPopupMenuItem<String>(
|
||||
value: _checkedValue1,
|
||||
checked: isChecked(_checkedValue1),
|
||||
child: new Text(_checkedValue1)
|
||||
child: Text(_checkedValue1)
|
||||
),
|
||||
new CheckedPopupMenuItem<String>(
|
||||
CheckedPopupMenuItem<String>(
|
||||
value: _checkedValue2,
|
||||
enabled: false,
|
||||
checked: isChecked(_checkedValue2),
|
||||
child: new Text(_checkedValue2)
|
||||
child: Text(_checkedValue2)
|
||||
),
|
||||
new CheckedPopupMenuItem<String>(
|
||||
CheckedPopupMenuItem<String>(
|
||||
value: _checkedValue3,
|
||||
checked: isChecked(_checkedValue3),
|
||||
child: new Text(_checkedValue3)
|
||||
child: Text(_checkedValue3)
|
||||
),
|
||||
new CheckedPopupMenuItem<String>(
|
||||
CheckedPopupMenuItem<String>(
|
||||
value: _checkedValue4,
|
||||
checked: isChecked(_checkedValue4),
|
||||
child: new Text(_checkedValue4)
|
||||
child: Text(_checkedValue4)
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
@@ -9,19 +9,19 @@ class ModalBottomSheetDemo extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: const Text('Modal bottom sheet')),
|
||||
body: new Center(
|
||||
child: new RaisedButton(
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Modal bottom sheet')),
|
||||
body: Center(
|
||||
child: RaisedButton(
|
||||
child: const Text('SHOW BOTTOM SHEET'),
|
||||
onPressed: () {
|
||||
showModalBottomSheet<void>(context: context, builder: (BuildContext context) {
|
||||
return new Container(
|
||||
child: new Padding(
|
||||
return Container(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(32.0),
|
||||
child: new Text('This is the modal bottom sheet. Tap anywhere to dismiss.',
|
||||
child: Text('This is the modal bottom sheet. Tap anywhere to dismiss.',
|
||||
textAlign: TextAlign.center,
|
||||
style: new TextStyle(
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).accentColor,
|
||||
fontSize: 24.0
|
||||
)
|
||||
|
||||
@@ -14,23 +14,23 @@ class OverscrollDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/overscroll';
|
||||
|
||||
@override
|
||||
OverscrollDemoState createState() => new OverscrollDemoState();
|
||||
OverscrollDemoState createState() => OverscrollDemoState();
|
||||
}
|
||||
|
||||
class OverscrollDemoState extends State<OverscrollDemo> {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey = new GlobalKey<RefreshIndicatorState>();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey = GlobalKey<RefreshIndicatorState>();
|
||||
static final List<String> _items = <String>[
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N'
|
||||
];
|
||||
|
||||
Future<Null> _handleRefresh() {
|
||||
final Completer<Null> completer = new Completer<Null>();
|
||||
new Timer(const Duration(seconds: 3), () { completer.complete(null); });
|
||||
final Completer<Null> completer = Completer<Null>();
|
||||
Timer(const Duration(seconds: 3), () { completer.complete(null); });
|
||||
return completer.future.then((_) {
|
||||
_scaffoldKey.currentState?.showSnackBar(new SnackBar(
|
||||
_scaffoldKey.currentState?.showSnackBar(SnackBar(
|
||||
content: const Text('Refresh complete'),
|
||||
action: new SnackBarAction(
|
||||
action: SnackBarAction(
|
||||
label: 'RETRY',
|
||||
onPressed: () {
|
||||
_refreshIndicatorKey.currentState.show();
|
||||
@@ -42,12 +42,12 @@ class OverscrollDemoState extends State<OverscrollDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: new AppBar(
|
||||
appBar: AppBar(
|
||||
title: const Text('Pull to refresh'),
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh),
|
||||
tooltip: 'Refresh',
|
||||
onPressed: () {
|
||||
@@ -56,18 +56,18 @@ class OverscrollDemoState extends State<OverscrollDemo> {
|
||||
),
|
||||
]
|
||||
),
|
||||
body: new RefreshIndicator(
|
||||
body: RefreshIndicator(
|
||||
key: _refreshIndicatorKey,
|
||||
onRefresh: _handleRefresh,
|
||||
child: new ListView.builder(
|
||||
child: ListView.builder(
|
||||
padding: kMaterialListPadding,
|
||||
itemCount: _items.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final String item = _items[index];
|
||||
return new ListTile(
|
||||
return ListTile(
|
||||
isThreeLine: true,
|
||||
leading: new CircleAvatar(child: new Text(item)),
|
||||
title: new Text('This item represents $item.'),
|
||||
leading: CircleAvatar(child: Text(item)),
|
||||
title: Text('This item represents $item.'),
|
||||
subtitle: const Text('Even more additional list item information appears on line three.'),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -19,23 +19,23 @@ class _PageSelector extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final TabController controller = DefaultTabController.of(context);
|
||||
final Color color = Theme.of(context).accentColor;
|
||||
return new SafeArea(
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 16.0),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
color: color,
|
||||
onPressed: () { _handleArrowButtonPress(context, -1); },
|
||||
tooltip: 'Page back'
|
||||
),
|
||||
new TabPageSelector(controller: controller),
|
||||
new IconButton(
|
||||
TabPageSelector(controller: controller),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.chevron_right),
|
||||
color: color,
|
||||
onPressed: () { _handleArrowButtonPress(context, 1); },
|
||||
@@ -45,18 +45,18 @@ class _PageSelector extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween
|
||||
)
|
||||
),
|
||||
new Expanded(
|
||||
child: new IconTheme(
|
||||
data: new IconThemeData(
|
||||
Expanded(
|
||||
child: IconTheme(
|
||||
data: IconThemeData(
|
||||
size: 128.0,
|
||||
color: color,
|
||||
),
|
||||
child: new TabBarView(
|
||||
child: TabBarView(
|
||||
children: icons.map((Icon icon) {
|
||||
return new Container(
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: new Card(
|
||||
child: new Center(
|
||||
child: Card(
|
||||
child: Center(
|
||||
child: icon,
|
||||
),
|
||||
),
|
||||
@@ -84,11 +84,11 @@ class PageSelectorDemo extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: const Text('Page selector')),
|
||||
body: new DefaultTabController(
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Page selector')),
|
||||
body: DefaultTabController(
|
||||
length: icons.length,
|
||||
child: new _PageSelector(icons: icons),
|
||||
child: _PageSelector(icons: icons),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ class PersistentBottomSheetDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/persistent-bottom-sheet';
|
||||
|
||||
@override
|
||||
_PersistentBottomSheetDemoState createState() => new _PersistentBottomSheetDemoState();
|
||||
_PersistentBottomSheetDemoState createState() => _PersistentBottomSheetDemoState();
|
||||
}
|
||||
|
||||
class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
VoidCallback _showBottomSheetCallback;
|
||||
|
||||
@@ -28,15 +28,15 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
|
||||
});
|
||||
_scaffoldKey.currentState.showBottomSheet<Null>((BuildContext context) {
|
||||
final ThemeData themeData = Theme.of(context);
|
||||
return new Container(
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border(top: new BorderSide(color: themeData.disabledColor))
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(top: BorderSide(color: themeData.disabledColor))
|
||||
),
|
||||
child: new Padding(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(32.0),
|
||||
child: new Text('This is a Material persistent bottom sheet. Drag downwards to dismiss it.',
|
||||
child: Text('This is a Material persistent bottom sheet. Drag downwards to dismiss it.',
|
||||
textAlign: TextAlign.center,
|
||||
style: new TextStyle(
|
||||
style: TextStyle(
|
||||
color: themeData.accentColor,
|
||||
fontSize: 24.0
|
||||
)
|
||||
@@ -57,10 +57,10 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return new AlertDialog(
|
||||
return AlertDialog(
|
||||
content: const Text('You tapped the floating action button.'),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
@@ -74,10 +74,10 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: new AppBar(title: const Text('Persistent bottom sheet')),
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
appBar: AppBar(title: const Text('Persistent bottom sheet')),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: _showMessage,
|
||||
backgroundColor: Colors.redAccent,
|
||||
child: const Icon(
|
||||
@@ -85,8 +85,8 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
|
||||
semanticLabel: 'Add',
|
||||
),
|
||||
),
|
||||
body: new Center(
|
||||
child: new RaisedButton(
|
||||
body: Center(
|
||||
child: RaisedButton(
|
||||
onPressed: _showBottomSheetCallback,
|
||||
child: const Text('SHOW BOTTOM SHEET')
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ class ProgressIndicatorDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/progress-indicator';
|
||||
|
||||
@override
|
||||
_ProgressIndicatorDemoState createState() => new _ProgressIndicatorDemoState();
|
||||
_ProgressIndicatorDemoState createState() => _ProgressIndicatorDemoState();
|
||||
}
|
||||
|
||||
class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with SingleTickerProviderStateMixin {
|
||||
@@ -18,13 +18,13 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with Sing
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = new AnimationController(
|
||||
_controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 1500),
|
||||
vsync: this,
|
||||
animationBehavior: AnimationBehavior.preserve,
|
||||
)..forward();
|
||||
|
||||
_animation = new CurvedAnimation(
|
||||
_animation = CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: const Interval(0.0, 0.9, curve: Curves.fastOutSlowIn),
|
||||
reverseCurve: Curves.fastOutSlowIn
|
||||
@@ -70,50 +70,50 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with Sing
|
||||
),
|
||||
const LinearProgressIndicator(),
|
||||
const LinearProgressIndicator(),
|
||||
new LinearProgressIndicator(value: _animation.value),
|
||||
new Row(
|
||||
LinearProgressIndicator(value: _animation.value),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
const CircularProgressIndicator(),
|
||||
new SizedBox(
|
||||
SizedBox(
|
||||
width: 20.0,
|
||||
height: 20.0,
|
||||
child: new CircularProgressIndicator(value: _animation.value)
|
||||
child: CircularProgressIndicator(value: _animation.value)
|
||||
),
|
||||
new SizedBox(
|
||||
SizedBox(
|
||||
width: 100.0,
|
||||
height: 20.0,
|
||||
child: new Text('${(_animation.value * 100.0).toStringAsFixed(1)}%',
|
||||
child: Text('${(_animation.value * 100.0).toStringAsFixed(1)}%',
|
||||
textAlign: TextAlign.right
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
return new Column(
|
||||
return Column(
|
||||
children: indicators
|
||||
.map((Widget c) => new Container(child: c, margin: const EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0)))
|
||||
.map((Widget c) => Container(child: c, margin: const EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0)))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: const Text('Progress indicators')),
|
||||
body: new Center(
|
||||
child: new SingleChildScrollView(
|
||||
child: new DefaultTextStyle(
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Progress indicators')),
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
child: DefaultTextStyle(
|
||||
style: Theme.of(context).textTheme.title,
|
||||
child: new GestureDetector(
|
||||
child: GestureDetector(
|
||||
onTap: _handleTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: new SafeArea(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Container(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 8.0),
|
||||
child: new AnimatedBuilder(
|
||||
child: AnimatedBuilder(
|
||||
animation: _animation,
|
||||
builder: _buildIndicators
|
||||
),
|
||||
|
||||
@@ -23,7 +23,7 @@ class ReorderableListDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/reorderable-list';
|
||||
|
||||
@override
|
||||
_ListDemoState createState() => new _ListDemoState();
|
||||
_ListDemoState createState() => _ListDemoState();
|
||||
}
|
||||
|
||||
class _ListItem {
|
||||
@@ -35,14 +35,14 @@ class _ListItem {
|
||||
}
|
||||
|
||||
class _ListDemoState extends State<ReorderableListDemo> {
|
||||
static final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
PersistentBottomSheetController<Null> _bottomSheet;
|
||||
_ReorderableListType _itemType = _ReorderableListType.threeLine;
|
||||
bool _reverseSort = false;
|
||||
final List<_ListItem> _items = <String>[
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
|
||||
].map((String item) => new _ListItem(item, false)).toList();
|
||||
].map((String item) => _ListItem(item, false)).toList();
|
||||
|
||||
void changeItemType(_ReorderableListType type) {
|
||||
setState(() {
|
||||
@@ -57,29 +57,29 @@ class _ListDemoState extends State<ReorderableListDemo> {
|
||||
void _showConfigurationSheet() {
|
||||
setState(() {
|
||||
_bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) {
|
||||
return new DecoratedBox(
|
||||
return DecoratedBox(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(top: BorderSide(color: Colors.black26)),
|
||||
),
|
||||
child: new ListView(
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
primary: false,
|
||||
children: <Widget>[
|
||||
new RadioListTile<_ReorderableListType>(
|
||||
RadioListTile<_ReorderableListType>(
|
||||
dense: true,
|
||||
title: const Text('Horizontal Avatars'),
|
||||
value: _ReorderableListType.horizontalAvatar,
|
||||
groupValue: _itemType,
|
||||
onChanged: changeItemType,
|
||||
),
|
||||
new RadioListTile<_ReorderableListType>(
|
||||
RadioListTile<_ReorderableListType>(
|
||||
dense: true,
|
||||
title: const Text('Vertical Avatars'),
|
||||
value: _ReorderableListType.verticalAvatar,
|
||||
groupValue: _itemType,
|
||||
onChanged: changeItemType,
|
||||
),
|
||||
new RadioListTile<_ReorderableListType>(
|
||||
RadioListTile<_ReorderableListType>(
|
||||
dense: true,
|
||||
title: const Text('Three-line'),
|
||||
value: _ReorderableListType.threeLine,
|
||||
@@ -109,8 +109,8 @@ class _ListDemoState extends State<ReorderableListDemo> {
|
||||
Widget listTile;
|
||||
switch (_itemType) {
|
||||
case _ReorderableListType.threeLine:
|
||||
listTile = new CheckboxListTile(
|
||||
key: new Key(item.value),
|
||||
listTile = CheckboxListTile(
|
||||
key: Key(item.value),
|
||||
isThreeLine: true,
|
||||
value: item.checkState ?? false,
|
||||
onChanged: (bool newValue) {
|
||||
@@ -118,18 +118,18 @@ class _ListDemoState extends State<ReorderableListDemo> {
|
||||
item.checkState = newValue;
|
||||
});
|
||||
},
|
||||
title: new Text('This item represents ${item.value}.'),
|
||||
title: Text('This item represents ${item.value}.'),
|
||||
subtitle: secondary,
|
||||
secondary: const Icon(Icons.drag_handle),
|
||||
);
|
||||
break;
|
||||
case _ReorderableListType.horizontalAvatar:
|
||||
case _ReorderableListType.verticalAvatar:
|
||||
listTile = new Container(
|
||||
key: new Key(item.value),
|
||||
listTile = Container(
|
||||
key: Key(item.value),
|
||||
height: 100.0,
|
||||
width: 100.0,
|
||||
child: new CircleAvatar(child: new Text(item.value),
|
||||
child: CircleAvatar(child: Text(item.value),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
);
|
||||
@@ -152,12 +152,12 @@ class _ListDemoState extends State<ReorderableListDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: scaffoldKey,
|
||||
appBar: new AppBar(
|
||||
appBar: AppBar(
|
||||
title: const Text('Reorderable list'),
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.sort_by_alpha),
|
||||
tooltip: 'Sort',
|
||||
onPressed: () {
|
||||
@@ -167,8 +167,8 @@ class _ListDemoState extends State<ReorderableListDemo> {
|
||||
});
|
||||
},
|
||||
),
|
||||
new IconButton(
|
||||
icon: new Icon(
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Theme.of(context).platform == TargetPlatform.iOS
|
||||
? Icons.more_horiz
|
||||
: Icons.more_vert,
|
||||
@@ -178,12 +178,12 @@ class _ListDemoState extends State<ReorderableListDemo> {
|
||||
),
|
||||
],
|
||||
),
|
||||
body: new Scrollbar(
|
||||
child: new ReorderableListView(
|
||||
body: Scrollbar(
|
||||
child: ReorderableListView(
|
||||
header: _itemType != _ReorderableListType.threeLine
|
||||
? new Padding(
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Text('Header of the list', style: Theme.of(context).textTheme.headline))
|
||||
child: Text('Header of the list', style: Theme.of(context).textTheme.headline))
|
||||
: null,
|
||||
onReorder: _onReorder,
|
||||
scrollDirection: _itemType == _ReorderableListType.horizontalAvatar ? Axis.horizontal : Axis.vertical,
|
||||
|
||||
@@ -37,7 +37,7 @@ class ScrollableTabsDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/scrollable-tabs';
|
||||
|
||||
@override
|
||||
ScrollableTabsDemoState createState() => new ScrollableTabsDemoState();
|
||||
ScrollableTabsDemoState createState() => ScrollableTabsDemoState();
|
||||
}
|
||||
|
||||
class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTickerProviderStateMixin {
|
||||
@@ -48,7 +48,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = new TabController(vsync: this, length: _allPages.length);
|
||||
_controller = TabController(vsync: this, length: _allPages.length);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -69,7 +69,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
|
||||
|
||||
switch(_demoStyle) {
|
||||
case TabsDemoStyle.iconsAndText:
|
||||
return new ShapeDecoration(
|
||||
return ShapeDecoration(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(4.0)),
|
||||
side: BorderSide(
|
||||
@@ -86,7 +86,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
|
||||
);
|
||||
|
||||
case TabsDemoStyle.iconsOnly:
|
||||
return new ShapeDecoration(
|
||||
return ShapeDecoration(
|
||||
shape: const CircleBorder(
|
||||
side: BorderSide(
|
||||
color: Colors.white24,
|
||||
@@ -101,7 +101,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
|
||||
);
|
||||
|
||||
case TabsDemoStyle.textOnly:
|
||||
return new ShapeDecoration(
|
||||
return ShapeDecoration(
|
||||
shape: const StadiumBorder(
|
||||
side: BorderSide(
|
||||
color: Colors.white24,
|
||||
@@ -121,11 +121,11 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Color iconColor = Theme.of(context).accentColor;
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Scrollable tabs'),
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.sentiment_very_satisfied),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@@ -133,7 +133,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
|
||||
});
|
||||
},
|
||||
),
|
||||
new PopupMenuButton<TabsDemoStyle>(
|
||||
PopupMenuButton<TabsDemoStyle>(
|
||||
onSelected: changeDemoStyle,
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<TabsDemoStyle>>[
|
||||
const PopupMenuItem<TabsDemoStyle>(
|
||||
@@ -151,7 +151,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
|
||||
],
|
||||
),
|
||||
],
|
||||
bottom: new TabBar(
|
||||
bottom: TabBar(
|
||||
controller: _controller,
|
||||
isScrollable: true,
|
||||
indicator: getIndicator(),
|
||||
@@ -159,28 +159,28 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
|
||||
assert(_demoStyle != null);
|
||||
switch (_demoStyle) {
|
||||
case TabsDemoStyle.iconsAndText:
|
||||
return new Tab(text: page.text, icon: new Icon(page.icon));
|
||||
return Tab(text: page.text, icon: Icon(page.icon));
|
||||
case TabsDemoStyle.iconsOnly:
|
||||
return new Tab(icon: new Icon(page.icon));
|
||||
return Tab(icon: Icon(page.icon));
|
||||
case TabsDemoStyle.textOnly:
|
||||
return new Tab(text: page.text);
|
||||
return Tab(text: page.text);
|
||||
}
|
||||
return null;
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
body: new TabBarView(
|
||||
body: TabBarView(
|
||||
controller: _controller,
|
||||
children: _allPages.map((_Page page) {
|
||||
return new SafeArea(
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Container(
|
||||
key: new ObjectKey(page.icon),
|
||||
child: Container(
|
||||
key: ObjectKey(page.icon),
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: new Card(
|
||||
child: new Center(
|
||||
child: new Icon(
|
||||
child: Card(
|
||||
child: Center(
|
||||
child: Icon(
|
||||
page.icon,
|
||||
color: iconColor,
|
||||
size: 128.0,
|
||||
|
||||
@@ -8,23 +8,23 @@ class SearchDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/search';
|
||||
|
||||
@override
|
||||
_SearchDemoState createState() => new _SearchDemoState();
|
||||
_SearchDemoState createState() => _SearchDemoState();
|
||||
}
|
||||
|
||||
class _SearchDemoState extends State<SearchDemo> {
|
||||
final _SearchDemoSearchDelegate _delegate = new _SearchDemoSearchDelegate();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final _SearchDemoSearchDelegate _delegate = _SearchDemoSearchDelegate();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
int _lastIntegerSelected;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: new AppBar(
|
||||
leading: new IconButton(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
tooltip: 'Navigation menu',
|
||||
icon: new AnimatedIcon(
|
||||
icon: AnimatedIcon(
|
||||
icon: AnimatedIcons.menu_arrow,
|
||||
color: Colors.white,
|
||||
progress: _delegate.transitionAnimation,
|
||||
@@ -35,7 +35,7 @@ class _SearchDemoState extends State<SearchDemo> {
|
||||
),
|
||||
title: const Text('Numbers'),
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
tooltip: 'Search',
|
||||
icon: const Icon(Icons.search),
|
||||
onPressed: () async {
|
||||
@@ -50,9 +50,9 @@ class _SearchDemoState extends State<SearchDemo> {
|
||||
}
|
||||
},
|
||||
),
|
||||
new IconButton(
|
||||
IconButton(
|
||||
tooltip: 'More (not implemented)',
|
||||
icon: new Icon(
|
||||
icon: Icon(
|
||||
Theme.of(context).platform == TargetPlatform.iOS
|
||||
? Icons.more_horiz
|
||||
: Icons.more_vert,
|
||||
@@ -61,15 +61,15 @@ class _SearchDemoState extends State<SearchDemo> {
|
||||
),
|
||||
],
|
||||
),
|
||||
body: new Center(
|
||||
child: new Column(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
new MergeSemantics(
|
||||
child: new Column(
|
||||
MergeSemantics(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
Text('Press the '),
|
||||
@@ -88,11 +88,11 @@ class _SearchDemoState extends State<SearchDemo> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 64.0),
|
||||
new Text('Last selected integer: ${_lastIntegerSelected ?? 'NONE' }.')
|
||||
Text('Last selected integer: ${_lastIntegerSelected ?? 'NONE' }.')
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: new FloatingActionButton.extended(
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
tooltip: 'Back', // Tests depend on this label to exit the demo.
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
@@ -100,8 +100,8 @@ class _SearchDemoState extends State<SearchDemo> {
|
||||
label: const Text('Close demo'),
|
||||
icon: const Icon(Icons.close),
|
||||
),
|
||||
drawer: new Drawer(
|
||||
child: new Column(
|
||||
drawer: Drawer(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
const UserAccountsDrawerHeader(
|
||||
accountName: Text('Peter Widget'),
|
||||
@@ -114,7 +114,7 @@ class _SearchDemoState extends State<SearchDemo> {
|
||||
),
|
||||
margin: EdgeInsets.zero,
|
||||
),
|
||||
new MediaQuery.removePadding(
|
||||
MediaQuery.removePadding(
|
||||
context: context,
|
||||
// DrawerHeader consumes top MediaQuery padding.
|
||||
removeTop: true,
|
||||
@@ -131,14 +131,14 @@ class _SearchDemoState extends State<SearchDemo> {
|
||||
}
|
||||
|
||||
class _SearchDemoSearchDelegate extends SearchDelegate<int> {
|
||||
final List<int> _data = new List<int>.generate(100001, (int i) => i).reversed.toList();
|
||||
final List<int> _data = List<int>.generate(100001, (int i) => i).reversed.toList();
|
||||
final List<int> _history = <int>[42607, 85604, 66374, 44, 174];
|
||||
|
||||
@override
|
||||
Widget buildLeading(BuildContext context) {
|
||||
return new IconButton(
|
||||
return IconButton(
|
||||
tooltip: 'Back',
|
||||
icon: new AnimatedIcon(
|
||||
icon: AnimatedIcon(
|
||||
icon: AnimatedIcons.menu_arrow,
|
||||
progress: transitionAnimation,
|
||||
),
|
||||
@@ -155,7 +155,7 @@ class _SearchDemoSearchDelegate extends SearchDelegate<int> {
|
||||
? _history
|
||||
: _data.where((int i) => '$i'.startsWith(query));
|
||||
|
||||
return new _SuggestionList(
|
||||
return _SuggestionList(
|
||||
query: query,
|
||||
suggestions: suggestions.map((int i) => '$i').toList(),
|
||||
onSelected: (String suggestion) {
|
||||
@@ -169,27 +169,27 @@ class _SearchDemoSearchDelegate extends SearchDelegate<int> {
|
||||
Widget buildResults(BuildContext context) {
|
||||
final int searched = int.tryParse(query);
|
||||
if (searched == null || !_data.contains(searched)) {
|
||||
return new Center(
|
||||
child: new Text(
|
||||
return Center(
|
||||
child: Text(
|
||||
'"$query"\n is not a valid integer between 0 and 100,000.\nTry again.',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return new ListView(
|
||||
return ListView(
|
||||
children: <Widget>[
|
||||
new _ResultCard(
|
||||
_ResultCard(
|
||||
title: 'This integer',
|
||||
integer: searched,
|
||||
searchDelegate: this,
|
||||
),
|
||||
new _ResultCard(
|
||||
_ResultCard(
|
||||
title: 'Next integer',
|
||||
integer: searched + 1,
|
||||
searchDelegate: this,
|
||||
),
|
||||
new _ResultCard(
|
||||
_ResultCard(
|
||||
title: 'Previous integer',
|
||||
integer: searched - 1,
|
||||
searchDelegate: this,
|
||||
@@ -202,14 +202,14 @@ class _SearchDemoSearchDelegate extends SearchDelegate<int> {
|
||||
List<Widget> buildActions(BuildContext context) {
|
||||
return <Widget>[
|
||||
query.isEmpty
|
||||
? new IconButton(
|
||||
? IconButton(
|
||||
tooltip: 'Voice Search',
|
||||
icon: const Icon(Icons.mic),
|
||||
onPressed: () {
|
||||
query = 'TODO: implement voice input';
|
||||
},
|
||||
)
|
||||
: new IconButton(
|
||||
: IconButton(
|
||||
tooltip: 'Clear',
|
||||
icon: const Icon(Icons.clear),
|
||||
onPressed: () {
|
||||
@@ -231,17 +231,17 @@ class _ResultCard extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return new GestureDetector(
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
searchDelegate.close(context, integer);
|
||||
},
|
||||
child: new Card(
|
||||
child: new Padding(
|
||||
child: Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new Text(title),
|
||||
new Text(
|
||||
Text(title),
|
||||
Text(
|
||||
'$integer',
|
||||
style: theme.textTheme.headline.copyWith(fontSize: 72.0),
|
||||
),
|
||||
@@ -263,18 +263,18 @@ class _SuggestionList extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return new ListView.builder(
|
||||
return ListView.builder(
|
||||
itemCount: suggestions.length,
|
||||
itemBuilder: (BuildContext context, int i) {
|
||||
final String suggestion = suggestions[i];
|
||||
return new ListTile(
|
||||
return ListTile(
|
||||
leading: query.isEmpty ? const Icon(Icons.history) : const Icon(null),
|
||||
title: new RichText(
|
||||
text: new TextSpan(
|
||||
title: RichText(
|
||||
text: TextSpan(
|
||||
text: suggestion.substring(0, query.length),
|
||||
style: theme.textTheme.subhead.copyWith(fontWeight: FontWeight.bold),
|
||||
children: <TextSpan>[
|
||||
new TextSpan(
|
||||
TextSpan(
|
||||
text: suggestion.substring(query.length),
|
||||
style: theme.textTheme.subhead,
|
||||
),
|
||||
|
||||
@@ -31,26 +31,26 @@ class SelectionControlsDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/selection-controls';
|
||||
|
||||
@override
|
||||
_SelectionControlsDemoState createState() => new _SelectionControlsDemoState();
|
||||
_SelectionControlsDemoState createState() => _SelectionControlsDemoState();
|
||||
}
|
||||
|
||||
class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<ComponentDemoTabData> demos = <ComponentDemoTabData>[
|
||||
new ComponentDemoTabData(
|
||||
ComponentDemoTabData(
|
||||
tabName: 'CHECKBOX',
|
||||
description: _checkboxText,
|
||||
demoWidget: buildCheckbox(),
|
||||
exampleCodeTag: _checkboxCode
|
||||
),
|
||||
new ComponentDemoTabData(
|
||||
ComponentDemoTabData(
|
||||
tabName: 'RADIO',
|
||||
description: _radioText,
|
||||
demoWidget: buildRadio(),
|
||||
exampleCodeTag: _radioCode
|
||||
),
|
||||
new ComponentDemoTabData(
|
||||
ComponentDemoTabData(
|
||||
tabName: 'SWITCH',
|
||||
description: _switchText,
|
||||
demoWidget: buildSwitch(),
|
||||
@@ -58,7 +58,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
||||
)
|
||||
];
|
||||
|
||||
return new TabbedComponentDemoScaffold(
|
||||
return TabbedComponentDemoScaffold(
|
||||
title: 'Selection controls',
|
||||
demos: demos
|
||||
);
|
||||
@@ -77,15 +77,15 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
||||
}
|
||||
|
||||
Widget buildCheckbox() {
|
||||
return new Align(
|
||||
return Align(
|
||||
alignment: const Alignment(0.0, -0.2),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Checkbox(
|
||||
Checkbox(
|
||||
value: checkboxValueA,
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
@@ -93,7 +93,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
||||
});
|
||||
},
|
||||
),
|
||||
new Checkbox(
|
||||
Checkbox(
|
||||
value: checkboxValueB,
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
@@ -101,7 +101,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
||||
});
|
||||
},
|
||||
),
|
||||
new Checkbox(
|
||||
Checkbox(
|
||||
value: checkboxValueC,
|
||||
tristate: true,
|
||||
onChanged: (bool value) {
|
||||
@@ -112,7 +112,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
||||
),
|
||||
],
|
||||
),
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: const <Widget>[
|
||||
// Disabled checkboxes
|
||||
@@ -127,25 +127,25 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
||||
}
|
||||
|
||||
Widget buildRadio() {
|
||||
return new Align(
|
||||
return Align(
|
||||
alignment: const Alignment(0.0, -0.2),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Radio<int>(
|
||||
Radio<int>(
|
||||
value: 0,
|
||||
groupValue: radioValue,
|
||||
onChanged: handleRadioValueChanged
|
||||
),
|
||||
new Radio<int>(
|
||||
Radio<int>(
|
||||
value: 1,
|
||||
groupValue: radioValue,
|
||||
onChanged: handleRadioValueChanged
|
||||
),
|
||||
new Radio<int>(
|
||||
Radio<int>(
|
||||
value: 2,
|
||||
groupValue: radioValue,
|
||||
onChanged: handleRadioValueChanged
|
||||
@@ -153,7 +153,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
||||
]
|
||||
),
|
||||
// Disabled radio buttons
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: const <Widget>[
|
||||
Radio<int>(
|
||||
@@ -179,12 +179,12 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
||||
}
|
||||
|
||||
Widget buildSwitch() {
|
||||
return new Align(
|
||||
return Align(
|
||||
alignment: const Alignment(0.0, -0.2),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Switch(
|
||||
Switch(
|
||||
value: switchValue,
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
|
||||
@@ -10,11 +10,11 @@ class SliderDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/slider';
|
||||
|
||||
@override
|
||||
_SliderDemoState createState() => new _SliderDemoState();
|
||||
_SliderDemoState createState() => _SliderDemoState();
|
||||
}
|
||||
|
||||
Path _triangle(double size, Offset thumbCenter, {bool invert = false}) {
|
||||
final Path thumbPath = new Path();
|
||||
final Path thumbPath = Path();
|
||||
final double height = math.sqrt(3.0) / 2.0;
|
||||
final double halfSide = size / 2.0;
|
||||
final double centerHeight = size * height / 3.0;
|
||||
@@ -35,7 +35,7 @@ class _CustomThumbShape extends SliderComponentShape {
|
||||
return isEnabled ? const Size.fromRadius(_thumbSize) : const Size.fromRadius(_disabledThumbSize);
|
||||
}
|
||||
|
||||
static final Tween<double> sizeTween = new Tween<double>(
|
||||
static final Tween<double> sizeTween = Tween<double>(
|
||||
begin: _disabledThumbSize,
|
||||
end: _thumbSize,
|
||||
);
|
||||
@@ -54,13 +54,13 @@ class _CustomThumbShape extends SliderComponentShape {
|
||||
double value,
|
||||
}) {
|
||||
final Canvas canvas = context.canvas;
|
||||
final ColorTween colorTween = new ColorTween(
|
||||
final ColorTween colorTween = ColorTween(
|
||||
begin: sliderTheme.disabledThumbColor,
|
||||
end: sliderTheme.thumbColor,
|
||||
);
|
||||
final double size = _thumbSize * sizeTween.evaluate(enableAnimation);
|
||||
final Path thumbPath = _triangle(size, thumbCenter);
|
||||
canvas.drawPath(thumbPath, new Paint()..color = colorTween.evaluate(enableAnimation));
|
||||
canvas.drawPath(thumbPath, Paint()..color = colorTween.evaluate(enableAnimation));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,10 +71,10 @@ class _CustomValueIndicatorShape extends SliderComponentShape {
|
||||
|
||||
@override
|
||||
Size getPreferredSize(bool isEnabled, bool isDiscrete) {
|
||||
return new Size.fromRadius(isEnabled ? _indicatorSize : _disabledIndicatorSize);
|
||||
return Size.fromRadius(isEnabled ? _indicatorSize : _disabledIndicatorSize);
|
||||
}
|
||||
|
||||
static final Tween<double> sizeTween = new Tween<double>(
|
||||
static final Tween<double> sizeTween = Tween<double>(
|
||||
begin: _disabledIndicatorSize,
|
||||
end: _indicatorSize,
|
||||
);
|
||||
@@ -93,16 +93,16 @@ class _CustomValueIndicatorShape extends SliderComponentShape {
|
||||
double value,
|
||||
}) {
|
||||
final Canvas canvas = context.canvas;
|
||||
final ColorTween enableColor = new ColorTween(
|
||||
final ColorTween enableColor = ColorTween(
|
||||
begin: sliderTheme.disabledThumbColor,
|
||||
end: sliderTheme.valueIndicatorColor,
|
||||
);
|
||||
final Tween<double> slideUpTween = new Tween<double>(
|
||||
final Tween<double> slideUpTween = Tween<double>(
|
||||
begin: 0.0,
|
||||
end: _slideUpHeight,
|
||||
);
|
||||
final double size = _indicatorSize * sizeTween.evaluate(enableAnimation);
|
||||
final Offset slideUpOffset = new Offset(0.0, -slideUpTween.evaluate(activationAnimation));
|
||||
final Offset slideUpOffset = Offset(0.0, -slideUpTween.evaluate(activationAnimation));
|
||||
final Path thumbPath = _triangle(
|
||||
size,
|
||||
thumbCenter + slideUpOffset,
|
||||
@@ -111,16 +111,16 @@ class _CustomValueIndicatorShape extends SliderComponentShape {
|
||||
final Color paintColor = enableColor.evaluate(enableAnimation).withAlpha((255.0 * activationAnimation.value).round());
|
||||
canvas.drawPath(
|
||||
thumbPath,
|
||||
new Paint()..color = paintColor,
|
||||
Paint()..color = paintColor,
|
||||
);
|
||||
canvas.drawLine(
|
||||
thumbCenter,
|
||||
thumbCenter + slideUpOffset,
|
||||
new Paint()
|
||||
Paint()
|
||||
..color = paintColor
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 2.0);
|
||||
labelPainter.paint(canvas, thumbCenter + slideUpOffset + new Offset(-labelPainter.width / 2.0, -labelPainter.height - 4.0));
|
||||
labelPainter.paint(canvas, thumbCenter + slideUpOffset + Offset(-labelPainter.width / 2.0, -labelPainter.height - 4.0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,17 +131,17 @@ class _SliderDemoState extends State<SliderDemo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: const Text('Sliders')),
|
||||
body: new Padding(
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Sliders')),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 40.0),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
new Column(
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Slider(
|
||||
Slider(
|
||||
value: _value,
|
||||
min: 0.0,
|
||||
max: 100.0,
|
||||
@@ -154,17 +154,17 @@ class _SliderDemoState extends State<SliderDemo> {
|
||||
const Text('Continuous'),
|
||||
],
|
||||
),
|
||||
new Column(
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: const <Widget>[
|
||||
Slider(value: 0.25, onChanged: null),
|
||||
Text('Disabled'),
|
||||
],
|
||||
),
|
||||
new Column(
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Slider(
|
||||
Slider(
|
||||
value: _discreteValue,
|
||||
min: 0.0,
|
||||
max: 200.0,
|
||||
@@ -179,10 +179,10 @@ class _SliderDemoState extends State<SliderDemo> {
|
||||
const Text('Discrete'),
|
||||
],
|
||||
),
|
||||
new Column(
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new SliderTheme(
|
||||
SliderTheme(
|
||||
data: theme.sliderTheme.copyWith(
|
||||
activeTrackColor: Colors.deepPurple,
|
||||
inactiveTrackColor: Colors.black26,
|
||||
@@ -191,11 +191,11 @@ class _SliderDemoState extends State<SliderDemo> {
|
||||
overlayColor: Colors.black12,
|
||||
thumbColor: Colors.deepPurple,
|
||||
valueIndicatorColor: Colors.deepPurpleAccent,
|
||||
thumbShape: new _CustomThumbShape(),
|
||||
valueIndicatorShape: new _CustomValueIndicatorShape(),
|
||||
thumbShape: _CustomThumbShape(),
|
||||
valueIndicatorShape: _CustomValueIndicatorShape(),
|
||||
valueIndicatorTextStyle: theme.accentTextTheme.body2.copyWith(color: Colors.black87),
|
||||
),
|
||||
child: new Slider(
|
||||
child: Slider(
|
||||
value: _discreteValue,
|
||||
min: 0.0,
|
||||
max: 200.0,
|
||||
|
||||
@@ -22,33 +22,33 @@ class SnackBarDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/snack-bar';
|
||||
|
||||
@override
|
||||
_SnackBarDemoState createState() => new _SnackBarDemoState();
|
||||
_SnackBarDemoState createState() => _SnackBarDemoState();
|
||||
}
|
||||
|
||||
class _SnackBarDemoState extends State<SnackBarDemo> {
|
||||
int _snackBarIndex = 1;
|
||||
|
||||
Widget buildBody(BuildContext context) {
|
||||
return new SafeArea(
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new ListView(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
children: <Widget>[
|
||||
const Text(_text1),
|
||||
const Text(_text2),
|
||||
new Center(
|
||||
child: new RaisedButton(
|
||||
Center(
|
||||
child: RaisedButton(
|
||||
child: const Text('SHOW A SNACKBAR'),
|
||||
onPressed: () {
|
||||
final int thisSnackBarIndex = _snackBarIndex++;
|
||||
Scaffold.of(context).showSnackBar(new SnackBar(
|
||||
content: new Text('This is snackbar #$thisSnackBarIndex.'),
|
||||
action: new SnackBarAction(
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: Text('This is snackbar #$thisSnackBarIndex.'),
|
||||
action: SnackBarAction(
|
||||
label: 'ACTION',
|
||||
onPressed: () {
|
||||
Scaffold.of(context).showSnackBar(new SnackBar(
|
||||
content: new Text('You pressed snackbar $thisSnackBarIndex\'s action.')
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: Text('You pressed snackbar $thisSnackBarIndex\'s action.')
|
||||
));
|
||||
}
|
||||
),
|
||||
@@ -59,7 +59,7 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
|
||||
const Text(_text3),
|
||||
]
|
||||
.map((Widget child) {
|
||||
return new Container(
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 12.0),
|
||||
child: child
|
||||
);
|
||||
@@ -71,11 +71,11 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Snackbar')
|
||||
),
|
||||
body: new Builder(
|
||||
body: Builder(
|
||||
// Create an inner BuildContext so that the snackBar onPressed methods
|
||||
// can refer to the Scaffold with Scaffold.of().
|
||||
builder: buildBody
|
||||
|
||||
@@ -25,7 +25,7 @@ class _CardData {
|
||||
}
|
||||
|
||||
final Map<_Page, List<_CardData>> _allPages = <_Page, List<_CardData>>{
|
||||
new _Page(label: 'HOME'): <_CardData>[
|
||||
_Page(label: 'HOME'): <_CardData>[
|
||||
const _CardData(
|
||||
title: 'Flatwear',
|
||||
imageAsset: 'products/flatwear.png',
|
||||
@@ -72,7 +72,7 @@ final Map<_Page, List<_CardData>> _allPages = <_Page, List<_CardData>>{
|
||||
imageAssetPackage: _kGalleryAssetsPackage,
|
||||
),
|
||||
],
|
||||
new _Page(label: 'APPAREL'): <_CardData>[
|
||||
_Page(label: 'APPAREL'): <_CardData>[
|
||||
const _CardData(
|
||||
title: 'Cloud-White Dress',
|
||||
imageAsset: 'products/dress.png',
|
||||
@@ -100,30 +100,30 @@ class _CardDataItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Card(
|
||||
child: new Padding(
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Align(
|
||||
Align(
|
||||
alignment: page.id == 'H'
|
||||
? Alignment.centerLeft
|
||||
: Alignment.centerRight,
|
||||
child: new CircleAvatar(child: new Text('${page.id}')),
|
||||
child: CircleAvatar(child: Text('${page.id}')),
|
||||
),
|
||||
new SizedBox(
|
||||
SizedBox(
|
||||
width: 144.0,
|
||||
height: 144.0,
|
||||
child: new Image.asset(
|
||||
child: Image.asset(
|
||||
data.imageAsset,
|
||||
package: data.imageAssetPackage,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
new Center(
|
||||
child: new Text(
|
||||
Center(
|
||||
child: Text(
|
||||
data.title,
|
||||
style: Theme.of(context).textTheme.title,
|
||||
),
|
||||
@@ -140,56 +140,56 @@ class TabsDemo extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new DefaultTabController(
|
||||
return DefaultTabController(
|
||||
length: _allPages.length,
|
||||
child: new Scaffold(
|
||||
body: new NestedScrollView(
|
||||
child: Scaffold(
|
||||
body: NestedScrollView(
|
||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||
return <Widget>[
|
||||
new SliverOverlapAbsorber(
|
||||
SliverOverlapAbsorber(
|
||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||
child: new SliverAppBar(
|
||||
child: SliverAppBar(
|
||||
title: const Text('Tabs and scrolling'),
|
||||
pinned: true,
|
||||
expandedHeight: 150.0,
|
||||
forceElevated: innerBoxIsScrolled,
|
||||
bottom: new TabBar(
|
||||
bottom: TabBar(
|
||||
tabs: _allPages.keys.map(
|
||||
(_Page page) => new Tab(text: page.label),
|
||||
(_Page page) => Tab(text: page.label),
|
||||
).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
];
|
||||
},
|
||||
body: new TabBarView(
|
||||
body: TabBarView(
|
||||
children: _allPages.keys.map((_Page page) {
|
||||
return new SafeArea(
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Builder(
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return new CustomScrollView(
|
||||
key: new PageStorageKey<_Page>(page),
|
||||
return CustomScrollView(
|
||||
key: PageStorageKey<_Page>(page),
|
||||
slivers: <Widget>[
|
||||
new SliverOverlapInjector(
|
||||
SliverOverlapInjector(
|
||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||
),
|
||||
new SliverPadding(
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8.0,
|
||||
horizontal: 16.0,
|
||||
),
|
||||
sliver: new SliverFixedExtentList(
|
||||
sliver: SliverFixedExtentList(
|
||||
itemExtent: _CardDataItem.height,
|
||||
delegate: new SliverChildBuilderDelegate(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
final _CardData data = _allPages[page][index];
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8.0,
|
||||
),
|
||||
child: new _CardDataItem(
|
||||
child: _CardDataItem(
|
||||
page: page,
|
||||
data: data,
|
||||
),
|
||||
|
||||
@@ -20,27 +20,27 @@ class _Page {
|
||||
Color get labelColor => colors != null ? colors.shade300 : Colors.grey.shade300;
|
||||
bool get fabDefined => colors != null && icon != null;
|
||||
Color get fabColor => colors.shade400;
|
||||
Icon get fabIcon => new Icon(icon);
|
||||
Key get fabKey => new ValueKey<Color>(fabColor);
|
||||
Icon get fabIcon => Icon(icon);
|
||||
Key get fabKey => ValueKey<Color>(fabColor);
|
||||
}
|
||||
|
||||
final List<_Page> _allPages = <_Page>[
|
||||
new _Page(label: 'Blue', colors: Colors.indigo, icon: Icons.add),
|
||||
new _Page(label: 'Eco', colors: Colors.green, icon: Icons.create),
|
||||
new _Page(label: 'No'),
|
||||
new _Page(label: 'Teal', colors: Colors.teal, icon: Icons.add),
|
||||
new _Page(label: 'Red', colors: Colors.red, icon: Icons.create),
|
||||
_Page(label: 'Blue', colors: Colors.indigo, icon: Icons.add),
|
||||
_Page(label: 'Eco', colors: Colors.green, icon: Icons.create),
|
||||
_Page(label: 'No'),
|
||||
_Page(label: 'Teal', colors: Colors.teal, icon: Icons.add),
|
||||
_Page(label: 'Red', colors: Colors.red, icon: Icons.create),
|
||||
];
|
||||
|
||||
class TabsFabDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/tabs-fab';
|
||||
|
||||
@override
|
||||
_TabsFabDemoState createState() => new _TabsFabDemoState();
|
||||
_TabsFabDemoState createState() => _TabsFabDemoState();
|
||||
}
|
||||
|
||||
class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStateMixin {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
TabController _controller;
|
||||
_Page _selectedPage;
|
||||
@@ -49,7 +49,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = new TabController(vsync: this, length: _allPages.length);
|
||||
_controller = TabController(vsync: this, length: _allPages.length);
|
||||
_controller.addListener(_handleTabSelection);
|
||||
_selectedPage = _allPages[0];
|
||||
}
|
||||
@@ -68,28 +68,28 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
|
||||
|
||||
void _showExplanatoryText() {
|
||||
_scaffoldKey.currentState.showBottomSheet<Null>((BuildContext context) {
|
||||
return new Container(
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border(top: new BorderSide(color: Theme.of(context).dividerColor))
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(top: BorderSide(color: Theme.of(context).dividerColor))
|
||||
),
|
||||
child: new Padding(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(32.0),
|
||||
child: new Text(_explanatoryText, style: Theme.of(context).textTheme.subhead)
|
||||
child: Text(_explanatoryText, style: Theme.of(context).textTheme.subhead)
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget buildTabView(_Page page) {
|
||||
return new Builder(
|
||||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
return new Container(
|
||||
key: new ValueKey<String>(page.label),
|
||||
return Container(
|
||||
key: ValueKey<String>(page.label),
|
||||
padding: const EdgeInsets.fromLTRB(48.0, 48.0, 48.0, 96.0),
|
||||
child: new Card(
|
||||
child: new Center(
|
||||
child: new Text(page.label,
|
||||
style: new TextStyle(
|
||||
child: Card(
|
||||
child: Center(
|
||||
child: Text(page.label,
|
||||
style: TextStyle(
|
||||
color: page.labelColor,
|
||||
fontSize: 32.0
|
||||
),
|
||||
@@ -107,17 +107,17 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
|
||||
return null;
|
||||
|
||||
if (_extendedButtons) {
|
||||
return new FloatingActionButton.extended(
|
||||
key: new ValueKey<Key>(page.fabKey),
|
||||
return FloatingActionButton.extended(
|
||||
key: ValueKey<Key>(page.fabKey),
|
||||
tooltip: 'Show explanation',
|
||||
backgroundColor: page.fabColor,
|
||||
icon: page.fabIcon,
|
||||
label: new Text(page.label.toUpperCase()),
|
||||
label: Text(page.label.toUpperCase()),
|
||||
onPressed: _showExplanatoryText
|
||||
);
|
||||
}
|
||||
|
||||
return new FloatingActionButton(
|
||||
return FloatingActionButton(
|
||||
key: page.fabKey,
|
||||
tooltip: 'Show explanation',
|
||||
backgroundColor: page.fabColor,
|
||||
@@ -128,16 +128,16 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: new AppBar(
|
||||
appBar: AppBar(
|
||||
title: const Text('FAB per tab'),
|
||||
bottom: new TabBar(
|
||||
bottom: TabBar(
|
||||
controller: _controller,
|
||||
tabs: _allPages.map((_Page page) => new Tab(text: page.label.toUpperCase())).toList(),
|
||||
tabs: _allPages.map((_Page page) => Tab(text: page.label.toUpperCase())).toList(),
|
||||
),
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.sentiment_very_satisfied),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@@ -148,7 +148,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
|
||||
],
|
||||
),
|
||||
floatingActionButton: buildFloatingActionButton(_selectedPage),
|
||||
body: new TabBarView(
|
||||
body: TabBarView(
|
||||
controller: _controller,
|
||||
children: _allPages.map(buildTabView).toList()
|
||||
),
|
||||
|
||||
@@ -13,7 +13,7 @@ class TextFormFieldDemo extends StatefulWidget {
|
||||
static const String routeName = '/material/text-form-field';
|
||||
|
||||
@override
|
||||
TextFormFieldDemoState createState() => new TextFormFieldDemoState();
|
||||
TextFormFieldDemoState createState() => TextFormFieldDemoState();
|
||||
}
|
||||
|
||||
class PersonData {
|
||||
@@ -43,7 +43,7 @@ class PasswordField extends StatefulWidget {
|
||||
final ValueChanged<String> onFieldSubmitted;
|
||||
|
||||
@override
|
||||
_PasswordFieldState createState() => new _PasswordFieldState();
|
||||
_PasswordFieldState createState() => _PasswordFieldState();
|
||||
}
|
||||
|
||||
class _PasswordFieldState extends State<PasswordField> {
|
||||
@@ -51,26 +51,26 @@ class _PasswordFieldState extends State<PasswordField> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new TextFormField(
|
||||
return TextFormField(
|
||||
key: widget.fieldKey,
|
||||
obscureText: _obscureText,
|
||||
maxLength: 8,
|
||||
onSaved: widget.onSaved,
|
||||
validator: widget.validator,
|
||||
onFieldSubmitted: widget.onFieldSubmitted,
|
||||
decoration: new InputDecoration(
|
||||
decoration: InputDecoration(
|
||||
border: const UnderlineInputBorder(),
|
||||
filled: true,
|
||||
hintText: widget.hintText,
|
||||
labelText: widget.labelText,
|
||||
helperText: widget.helperText,
|
||||
suffixIcon: new GestureDetector(
|
||||
suffixIcon: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_obscureText = !_obscureText;
|
||||
});
|
||||
},
|
||||
child: new Icon(_obscureText ? Icons.visibility : Icons.visibility_off),
|
||||
child: Icon(_obscureText ? Icons.visibility : Icons.visibility_off),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -78,22 +78,22 @@ class _PasswordFieldState extends State<PasswordField> {
|
||||
}
|
||||
|
||||
class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
PersonData person = new PersonData();
|
||||
PersonData person = PersonData();
|
||||
|
||||
void showInSnackBar(String value) {
|
||||
_scaffoldKey.currentState.showSnackBar(new SnackBar(
|
||||
content: new Text(value)
|
||||
_scaffoldKey.currentState.showSnackBar(SnackBar(
|
||||
content: Text(value)
|
||||
));
|
||||
}
|
||||
|
||||
bool _autovalidate = false;
|
||||
bool _formWasEdited = false;
|
||||
|
||||
final GlobalKey<FormState> _formKey = new GlobalKey<FormState>();
|
||||
final GlobalKey<FormFieldState<String>> _passwordFieldKey = new GlobalKey<FormFieldState<String>>();
|
||||
final _UsNumberTextInputFormatter _phoneNumberFormatter = new _UsNumberTextInputFormatter();
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
final GlobalKey<FormFieldState<String>> _passwordFieldKey = GlobalKey<FormFieldState<String>>();
|
||||
final _UsNumberTextInputFormatter _phoneNumberFormatter = _UsNumberTextInputFormatter();
|
||||
void _handleSubmitted() {
|
||||
final FormState form = _formKey.currentState;
|
||||
if (!form.validate()) {
|
||||
@@ -109,7 +109,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
_formWasEdited = true;
|
||||
if (value.isEmpty)
|
||||
return 'Name is required.';
|
||||
final RegExp nameExp = new RegExp(r'^[A-Za-z ]+$');
|
||||
final RegExp nameExp = RegExp(r'^[A-Za-z ]+$');
|
||||
if (!nameExp.hasMatch(value))
|
||||
return 'Please enter only alphabetical characters.';
|
||||
return null;
|
||||
@@ -117,7 +117,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
|
||||
String _validatePhoneNumber(String value) {
|
||||
_formWasEdited = true;
|
||||
final RegExp phoneExp = new RegExp(r'^\(\d\d\d\) \d\d\d\-\d\d\d\d$');
|
||||
final RegExp phoneExp = RegExp(r'^\(\d\d\d\) \d\d\d\-\d\d\d\d$');
|
||||
if (!phoneExp.hasMatch(value))
|
||||
return '(###) ###-#### - Enter a US phone number.';
|
||||
return null;
|
||||
@@ -141,15 +141,15 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
return await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return new AlertDialog(
|
||||
return AlertDialog(
|
||||
title: const Text('This form has errors'),
|
||||
content: const Text('Really leave this form?'),
|
||||
actions: <Widget> [
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('YES'),
|
||||
onPressed: () { Navigator.of(context).pop(true); },
|
||||
),
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('NO'),
|
||||
onPressed: () { Navigator.of(context).pop(false); },
|
||||
),
|
||||
@@ -161,25 +161,25 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: new AppBar(
|
||||
appBar: AppBar(
|
||||
title: const Text('Text fields'),
|
||||
),
|
||||
body: new SafeArea(
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Form(
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
autovalidate: _autovalidate,
|
||||
onWillPop: _warnUserAboutInvalidData,
|
||||
child: new SingleChildScrollView(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
const SizedBox(height: 24.0),
|
||||
new TextFormField(
|
||||
TextFormField(
|
||||
textCapitalization: TextCapitalization.words,
|
||||
decoration: const InputDecoration(
|
||||
border: UnderlineInputBorder(),
|
||||
@@ -192,7 +192,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
validator: _validateName,
|
||||
),
|
||||
const SizedBox(height: 24.0),
|
||||
new TextFormField(
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(
|
||||
border: UnderlineInputBorder(),
|
||||
filled: true,
|
||||
@@ -212,7 +212,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24.0),
|
||||
new TextFormField(
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(
|
||||
border: UnderlineInputBorder(),
|
||||
filled: true,
|
||||
@@ -224,7 +224,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
onSaved: (String value) { person.email = value; },
|
||||
),
|
||||
const SizedBox(height: 24.0),
|
||||
new TextFormField(
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
hintText: 'Tell us about yourself',
|
||||
@@ -234,7 +234,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
maxLines: 3,
|
||||
),
|
||||
const SizedBox(height: 24.0),
|
||||
new TextFormField(
|
||||
TextFormField(
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
@@ -246,7 +246,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
maxLines: 1,
|
||||
),
|
||||
const SizedBox(height: 24.0),
|
||||
new PasswordField(
|
||||
PasswordField(
|
||||
fieldKey: _passwordFieldKey,
|
||||
helperText: 'No more than 8 characters.',
|
||||
labelText: 'Password *',
|
||||
@@ -257,7 +257,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24.0),
|
||||
new TextFormField(
|
||||
TextFormField(
|
||||
enabled: person.password != null && person.password.isNotEmpty,
|
||||
decoration: const InputDecoration(
|
||||
border: UnderlineInputBorder(),
|
||||
@@ -269,14 +269,14 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
validator: _validatePassword,
|
||||
),
|
||||
const SizedBox(height: 24.0),
|
||||
new Center(
|
||||
child: new RaisedButton(
|
||||
Center(
|
||||
child: RaisedButton(
|
||||
child: const Text('SUBMIT'),
|
||||
onPressed: _handleSubmitted,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24.0),
|
||||
new Text(
|
||||
Text(
|
||||
'* indicates required field',
|
||||
style: Theme.of(context).textTheme.caption
|
||||
),
|
||||
@@ -300,7 +300,7 @@ class _UsNumberTextInputFormatter extends TextInputFormatter {
|
||||
final int newTextLength = newValue.text.length;
|
||||
int selectionIndex = newValue.selection.end;
|
||||
int usedSubstringIndex = 0;
|
||||
final StringBuffer newText = new StringBuffer();
|
||||
final StringBuffer newText = StringBuffer();
|
||||
if (newTextLength >= 1) {
|
||||
newText.write('(');
|
||||
if (newValue.selection.end >= 1)
|
||||
@@ -324,9 +324,9 @@ class _UsNumberTextInputFormatter extends TextInputFormatter {
|
||||
// Dump the rest.
|
||||
if (newTextLength >= usedSubstringIndex)
|
||||
newText.write(newValue.text.substring(usedSubstringIndex));
|
||||
return new TextEditingValue(
|
||||
return TextEditingValue(
|
||||
text: newText.toString(),
|
||||
selection: new TextSelection.collapsed(offset: selectionIndex),
|
||||
selection: TextSelection.collapsed(offset: selectionIndex),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,34 +16,34 @@ class TooltipDemo extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Tooltips')
|
||||
),
|
||||
body: new Builder(
|
||||
body: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return new SafeArea(
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new ListView(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
new Text(_introText, style: theme.textTheme.subhead),
|
||||
new Row(
|
||||
Text(_introText, style: theme.textTheme.subhead),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
new Text('Long press the ', style: theme.textTheme.subhead),
|
||||
new Tooltip(
|
||||
Text('Long press the ', style: theme.textTheme.subhead),
|
||||
Tooltip(
|
||||
message: 'call icon',
|
||||
child: new Icon(
|
||||
child: Icon(
|
||||
Icons.call,
|
||||
size: 18.0,
|
||||
color: theme.iconTheme.color
|
||||
)
|
||||
),
|
||||
new Text(' icon.', style: theme.textTheme.subhead)
|
||||
Text(' icon.', style: theme.textTheme.subhead)
|
||||
]
|
||||
),
|
||||
new Center(
|
||||
child: new IconButton(
|
||||
Center(
|
||||
child: IconButton(
|
||||
iconSize: 48.0,
|
||||
icon: const Icon(Icons.call),
|
||||
color: theme.iconTheme.color,
|
||||
@@ -57,7 +57,7 @@ class TooltipDemo extends StatelessWidget {
|
||||
)
|
||||
]
|
||||
.map((Widget widget) {
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 16.0, left: 16.0, right: 16.0),
|
||||
child: widget
|
||||
);
|
||||
|
||||
@@ -9,12 +9,12 @@ class TwoLevelListDemo extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: const Text('Expand/collapse list control')),
|
||||
body: new ListView(
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Expand/collapse list control')),
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
const ListTile(title: Text('Top')),
|
||||
new ExpansionTile(
|
||||
ExpansionTile(
|
||||
title: const Text('Sublist'),
|
||||
backgroundColor: Theme.of(context).accentColor.withOpacity(0.025),
|
||||
children: const <Widget>[
|
||||
|
||||
@@ -11,7 +11,7 @@ class PestoDemo extends StatelessWidget {
|
||||
static const String routeName = '/pesto';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => new PestoHome();
|
||||
Widget build(BuildContext context) => PestoHome();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ const double _kAppBarHeight = 128.0;
|
||||
const double _kFabHalfSize = 28.0; // TODO(mpcomplete): needs to adapt to screen size
|
||||
const double _kRecipePageMaxWidth = 500.0;
|
||||
|
||||
final Set<Recipe> _favoriteRecipes = new Set<Recipe>();
|
||||
final Set<Recipe> _favoriteRecipes = Set<Recipe>();
|
||||
|
||||
final ThemeData _kTheme = new ThemeData(
|
||||
final ThemeData _kTheme = ThemeData(
|
||||
brightness: Brightness.light,
|
||||
primarySwatch: Colors.teal,
|
||||
accentColor: Colors.redAccent,
|
||||
@@ -39,7 +39,7 @@ class PestoHome extends StatelessWidget {
|
||||
class PestoFavorites extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new RecipeGridPage(recipes: _favoriteRecipes.toList());
|
||||
return RecipeGridPage(recipes: _favoriteRecipes.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,20 +69,20 @@ class RecipeGridPage extends StatefulWidget {
|
||||
final List<Recipe> recipes;
|
||||
|
||||
@override
|
||||
_RecipeGridPageState createState() => new _RecipeGridPageState();
|
||||
_RecipeGridPageState createState() => _RecipeGridPageState();
|
||||
}
|
||||
|
||||
class _RecipeGridPageState extends State<RecipeGridPage> {
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double statusBarHeight = MediaQuery.of(context).padding.top;
|
||||
return new Theme(
|
||||
return Theme(
|
||||
data: _kTheme.copyWith(platform: Theme.of(context).platform),
|
||||
child: new Scaffold(
|
||||
child: Scaffold(
|
||||
key: scaffoldKey,
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.edit),
|
||||
onPressed: () {
|
||||
scaffoldKey.currentState.showSnackBar(const SnackBar(
|
||||
@@ -90,7 +90,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
|
||||
));
|
||||
},
|
||||
),
|
||||
body: new CustomScrollView(
|
||||
body: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
_buildAppBar(context, statusBarHeight),
|
||||
_buildBody(context, statusBarHeight),
|
||||
@@ -101,11 +101,11 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
|
||||
}
|
||||
|
||||
Widget _buildAppBar(BuildContext context, double statusBarHeight) {
|
||||
return new SliverAppBar(
|
||||
return SliverAppBar(
|
||||
pinned: true,
|
||||
expandedHeight: _kAppBarHeight,
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.search),
|
||||
tooltip: 'Search',
|
||||
onPressed: () {
|
||||
@@ -115,20 +115,20 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
|
||||
},
|
||||
),
|
||||
],
|
||||
flexibleSpace: new LayoutBuilder(
|
||||
flexibleSpace: LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) {
|
||||
final Size size = constraints.biggest;
|
||||
final double appBarHeight = size.height - statusBarHeight;
|
||||
final double t = (appBarHeight - kToolbarHeight) / (_kAppBarHeight - kToolbarHeight);
|
||||
final double extraPadding = new Tween<double>(begin: 10.0, end: 24.0).lerp(t);
|
||||
final double extraPadding = Tween<double>(begin: 10.0, end: 24.0).lerp(t);
|
||||
final double logoHeight = appBarHeight - 1.5 * extraPadding;
|
||||
return new Padding(
|
||||
padding: new EdgeInsets.only(
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: statusBarHeight + 0.5 * extraPadding,
|
||||
bottom: extraPadding,
|
||||
),
|
||||
child: new Center(
|
||||
child: new PestoLogo(height: logoHeight, t: t.clamp(0.0, 1.0))
|
||||
child: Center(
|
||||
child: PestoLogo(height: logoHeight, t: t.clamp(0.0, 1.0))
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -138,24 +138,24 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
|
||||
|
||||
Widget _buildBody(BuildContext context, double statusBarHeight) {
|
||||
final EdgeInsets mediaPadding = MediaQuery.of(context).padding;
|
||||
final EdgeInsets padding = new EdgeInsets.only(
|
||||
final EdgeInsets padding = EdgeInsets.only(
|
||||
top: 8.0,
|
||||
left: 8.0 + mediaPadding.left,
|
||||
right: 8.0 + mediaPadding.right,
|
||||
bottom: 8.0
|
||||
);
|
||||
return new SliverPadding(
|
||||
return SliverPadding(
|
||||
padding: padding,
|
||||
sliver: new SliverGrid(
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: _kRecipePageMaxWidth,
|
||||
crossAxisSpacing: 8.0,
|
||||
mainAxisSpacing: 8.0,
|
||||
),
|
||||
delegate: new SliverChildBuilderDelegate(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
final Recipe recipe = widget.recipes[index];
|
||||
return new RecipeCard(
|
||||
return RecipeCard(
|
||||
recipe: recipe,
|
||||
onTap: () { showRecipePage(context, recipe); },
|
||||
);
|
||||
@@ -167,19 +167,19 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
|
||||
}
|
||||
|
||||
void showFavoritesPage(BuildContext context) {
|
||||
Navigator.push(context, new MaterialPageRoute<void>(
|
||||
Navigator.push(context, MaterialPageRoute<void>(
|
||||
settings: const RouteSettings(name: '/pesto/favorites'),
|
||||
builder: (BuildContext context) => new PestoFavorites(),
|
||||
builder: (BuildContext context) => PestoFavorites(),
|
||||
));
|
||||
}
|
||||
|
||||
void showRecipePage(BuildContext context, Recipe recipe) {
|
||||
Navigator.push(context, new MaterialPageRoute<void>(
|
||||
Navigator.push(context, MaterialPageRoute<void>(
|
||||
settings: const RouteSettings(name: '/pesto/recipe'),
|
||||
builder: (BuildContext context) {
|
||||
return new Theme(
|
||||
return Theme(
|
||||
data: _kTheme.copyWith(platform: Theme.of(context).platform),
|
||||
child: new RecipePage(recipe: recipe),
|
||||
child: RecipePage(recipe: recipe),
|
||||
);
|
||||
},
|
||||
));
|
||||
@@ -193,7 +193,7 @@ class PestoLogo extends StatefulWidget {
|
||||
final double t;
|
||||
|
||||
@override
|
||||
_PestoLogoState createState() => new _PestoLogoState();
|
||||
_PestoLogoState createState() => _PestoLogoState();
|
||||
}
|
||||
|
||||
class _PestoLogoState extends State<PestoLogo> {
|
||||
@@ -203,41 +203,41 @@ class _PestoLogoState extends State<PestoLogo> {
|
||||
static const double kImageHeight = 108.0;
|
||||
static const double kTextHeight = 48.0;
|
||||
final TextStyle titleStyle = const PestoStyle(fontSize: kTextHeight, fontWeight: FontWeight.w900, color: Colors.white, letterSpacing: 3.0);
|
||||
final RectTween _textRectTween = new RectTween(
|
||||
begin: new Rect.fromLTWH(0.0, kLogoHeight, kLogoWidth, kTextHeight),
|
||||
end: new Rect.fromLTWH(0.0, kImageHeight, kLogoWidth, kTextHeight)
|
||||
final RectTween _textRectTween = RectTween(
|
||||
begin: Rect.fromLTWH(0.0, kLogoHeight, kLogoWidth, kTextHeight),
|
||||
end: Rect.fromLTWH(0.0, kImageHeight, kLogoWidth, kTextHeight)
|
||||
);
|
||||
final Curve _textOpacity = const Interval(0.4, 1.0, curve: Curves.easeInOut);
|
||||
final RectTween _imageRectTween = new RectTween(
|
||||
begin: new Rect.fromLTWH(0.0, 0.0, kLogoWidth, kLogoHeight),
|
||||
end: new Rect.fromLTWH(0.0, 0.0, kLogoWidth, kImageHeight),
|
||||
final RectTween _imageRectTween = RectTween(
|
||||
begin: Rect.fromLTWH(0.0, 0.0, kLogoWidth, kLogoHeight),
|
||||
end: Rect.fromLTWH(0.0, 0.0, kLogoWidth, kImageHeight),
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Semantics(
|
||||
return Semantics(
|
||||
namesRoute: true,
|
||||
child: new Transform(
|
||||
transform: new Matrix4.identity()..scale(widget.height / kLogoHeight),
|
||||
child: Transform(
|
||||
transform: Matrix4.identity()..scale(widget.height / kLogoHeight),
|
||||
alignment: Alignment.topCenter,
|
||||
child: new SizedBox(
|
||||
child: SizedBox(
|
||||
width: kLogoWidth,
|
||||
child: new Stack(
|
||||
child: Stack(
|
||||
overflow: Overflow.visible,
|
||||
children: <Widget>[
|
||||
new Positioned.fromRect(
|
||||
Positioned.fromRect(
|
||||
rect: _imageRectTween.lerp(widget.t),
|
||||
child: new Image.asset(
|
||||
child: Image.asset(
|
||||
_kSmallLogoImage,
|
||||
package: _kGalleryAssetsPackage,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
new Positioned.fromRect(
|
||||
Positioned.fromRect(
|
||||
rect: _textRectTween.lerp(widget.t),
|
||||
child: new Opacity(
|
||||
child: Opacity(
|
||||
opacity: _textOpacity.transform(widget.t),
|
||||
child: new Text('PESTO', style: titleStyle, textAlign: TextAlign.center),
|
||||
child: Text('PESTO', style: titleStyle, textAlign: TextAlign.center),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -260,13 +260,13 @@ class RecipeCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new GestureDetector(
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: new Card(
|
||||
child: new Column(
|
||||
child: Card(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Hero(
|
||||
Hero(
|
||||
tag: 'packages/$_kGalleryAssetsPackage/${recipe.imagePath}',
|
||||
child: AspectRatio(
|
||||
aspectRatio: 4.0 / 3.0,
|
||||
@@ -278,25 +278,25 @@ class RecipeCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
new Expanded(
|
||||
child: new Row(
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: new Image.asset(
|
||||
child: Image.asset(
|
||||
recipe.ingredientsImagePath,
|
||||
package: recipe.ingredientsImagePackage,
|
||||
width: 48.0,
|
||||
height: 48.0,
|
||||
),
|
||||
),
|
||||
new Expanded(
|
||||
child: new Column(
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
new Text(recipe.name, style: titleStyle, softWrap: false, overflow: TextOverflow.ellipsis),
|
||||
new Text(recipe.author, style: authorStyle),
|
||||
Text(recipe.name, style: titleStyle, softWrap: false, overflow: TextOverflow.ellipsis),
|
||||
Text(recipe.author, style: authorStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -317,11 +317,11 @@ class RecipePage extends StatefulWidget {
|
||||
final Recipe recipe;
|
||||
|
||||
@override
|
||||
_RecipePageState createState() => new _RecipePageState();
|
||||
_RecipePageState createState() => _RecipePageState();
|
||||
}
|
||||
|
||||
class _RecipePageState extends State<RecipePage> {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final TextStyle menuItemStyle = const PestoStyle(fontSize: 15.0, color: Colors.black54, height: 24.0/15.0);
|
||||
|
||||
double _getAppBarHeight(BuildContext context) => MediaQuery.of(context).size.height * 0.3;
|
||||
@@ -335,31 +335,31 @@ class _RecipePageState extends State<RecipePage> {
|
||||
final Size screenSize = MediaQuery.of(context).size;
|
||||
final bool fullWidth = screenSize.width < _kRecipePageMaxWidth;
|
||||
final bool isFavorite = _favoriteRecipes.contains(widget.recipe);
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
body: new Stack(
|
||||
body: Stack(
|
||||
children: <Widget>[
|
||||
new Positioned(
|
||||
Positioned(
|
||||
top: 0.0,
|
||||
left: 0.0,
|
||||
right: 0.0,
|
||||
height: appBarHeight + _kFabHalfSize,
|
||||
child: new Hero(
|
||||
child: Hero(
|
||||
tag: 'packages/$_kGalleryAssetsPackage/${widget.recipe.imagePath}',
|
||||
child: new Image.asset(
|
||||
child: Image.asset(
|
||||
widget.recipe.imagePath,
|
||||
package: widget.recipe.imagePackage,
|
||||
fit: fullWidth ? BoxFit.fitWidth : BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
new CustomScrollView(
|
||||
CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
new SliverAppBar(
|
||||
SliverAppBar(
|
||||
expandedHeight: appBarHeight - _kFabHalfSize,
|
||||
backgroundColor: Colors.transparent,
|
||||
actions: <Widget>[
|
||||
new PopupMenuButton<String>(
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (String item) {},
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
|
||||
_buildMenuItem(Icons.share, 'Tweet recipe'),
|
||||
@@ -381,18 +381,18 @@ class _RecipePageState extends State<RecipePage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
new SliverToBoxAdapter(
|
||||
child: new Stack(
|
||||
SliverToBoxAdapter(
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
padding: const EdgeInsets.only(top: _kFabHalfSize),
|
||||
width: fullWidth ? null : _kRecipePageMaxWidth,
|
||||
child: new RecipeSheet(recipe: widget.recipe),
|
||||
child: RecipeSheet(recipe: widget.recipe),
|
||||
),
|
||||
new Positioned(
|
||||
Positioned(
|
||||
right: 16.0,
|
||||
child: new FloatingActionButton(
|
||||
child: new Icon(isFavorite ? Icons.favorite : Icons.favorite_border),
|
||||
child: FloatingActionButton(
|
||||
child: Icon(isFavorite ? Icons.favorite : Icons.favorite_border),
|
||||
onPressed: _toggleFavorite,
|
||||
),
|
||||
),
|
||||
@@ -407,14 +407,14 @@ class _RecipePageState extends State<RecipePage> {
|
||||
}
|
||||
|
||||
PopupMenuItem<String> _buildMenuItem(IconData icon, String label) {
|
||||
return new PopupMenuItem<String>(
|
||||
child: new Row(
|
||||
return PopupMenuItem<String>(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 24.0),
|
||||
child: new Icon(icon, color: Colors.black54)
|
||||
child: Icon(icon, color: Colors.black54)
|
||||
),
|
||||
new Text(label, style: menuItemStyle),
|
||||
Text(label, style: menuItemStyle),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -435,7 +435,7 @@ class RecipeSheet extends StatelessWidget {
|
||||
final TextStyle titleStyle = const PestoStyle(fontSize: 34.0);
|
||||
final TextStyle descriptionStyle = const PestoStyle(fontSize: 15.0, color: Colors.black54, height: 24.0/15.0);
|
||||
final TextStyle itemStyle = const PestoStyle(fontSize: 15.0, height: 24.0/15.0);
|
||||
final TextStyle itemAmountStyle = new PestoStyle(fontSize: 15.0, color: _kTheme.primaryColor, height: 24.0/15.0);
|
||||
final TextStyle itemAmountStyle = PestoStyle(fontSize: 15.0, color: _kTheme.primaryColor, height: 24.0/15.0);
|
||||
final TextStyle headingStyle = const PestoStyle(fontSize: 16.0, fontWeight: FontWeight.bold, height: 24.0/15.0);
|
||||
|
||||
RecipeSheet({ Key key, this.recipe }) : super(key: key);
|
||||
@@ -444,22 +444,22 @@ class RecipeSheet extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Material(
|
||||
child: new SafeArea(
|
||||
return Material(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Padding(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 40.0),
|
||||
child: new Table(
|
||||
child: Table(
|
||||
columnWidths: const <int, TableColumnWidth>{
|
||||
0: FixedColumnWidth(64.0)
|
||||
},
|
||||
children: <TableRow>[
|
||||
new TableRow(
|
||||
TableRow(
|
||||
children: <Widget>[
|
||||
new TableCell(
|
||||
TableCell(
|
||||
verticalAlignment: TableCellVerticalAlignment.middle,
|
||||
child: new Image.asset(
|
||||
child: Image.asset(
|
||||
recipe.ingredientsImagePath,
|
||||
package: recipe.ingredientsImagePackage,
|
||||
width: 32.0,
|
||||
@@ -468,27 +468,27 @@ class RecipeSheet extends StatelessWidget {
|
||||
fit: BoxFit.scaleDown
|
||||
)
|
||||
),
|
||||
new TableCell(
|
||||
TableCell(
|
||||
verticalAlignment: TableCellVerticalAlignment.middle,
|
||||
child: new Text(recipe.name, style: titleStyle)
|
||||
child: Text(recipe.name, style: titleStyle)
|
||||
),
|
||||
]
|
||||
),
|
||||
new TableRow(
|
||||
TableRow(
|
||||
children: <Widget>[
|
||||
const SizedBox(),
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0, bottom: 4.0),
|
||||
child: new Text(recipe.description, style: descriptionStyle)
|
||||
child: Text(recipe.description, style: descriptionStyle)
|
||||
),
|
||||
]
|
||||
),
|
||||
new TableRow(
|
||||
TableRow(
|
||||
children: <Widget>[
|
||||
const SizedBox(),
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 24.0, bottom: 4.0),
|
||||
child: new Text('Ingredients', style: headingStyle)
|
||||
child: Text('Ingredients', style: headingStyle)
|
||||
),
|
||||
]
|
||||
),
|
||||
@@ -497,12 +497,12 @@ class RecipeSheet extends StatelessWidget {
|
||||
return _buildItemRow(ingredient.amount, ingredient.description);
|
||||
}
|
||||
))..add(
|
||||
new TableRow(
|
||||
TableRow(
|
||||
children: <Widget>[
|
||||
const SizedBox(),
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 24.0, bottom: 4.0),
|
||||
child: new Text('Steps', style: headingStyle)
|
||||
child: Text('Steps', style: headingStyle)
|
||||
),
|
||||
]
|
||||
)
|
||||
@@ -518,15 +518,15 @@ class RecipeSheet extends StatelessWidget {
|
||||
}
|
||||
|
||||
TableRow _buildItemRow(String left, String right) {
|
||||
return new TableRow(
|
||||
return TableRow(
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
child: new Text(left, style: itemAmountStyle),
|
||||
child: Text(left, style: itemAmountStyle),
|
||||
),
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
child: new Text(right, style: itemStyle),
|
||||
child: Text(right, style: itemStyle),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -274,5 +274,5 @@ const List<Product> _allProducts = <Product> [
|
||||
|
||||
List<Product> allProducts() {
|
||||
assert(_allProducts.every((Product product) => product.isValid()));
|
||||
return new List<Product>.unmodifiable(_allProducts);
|
||||
return List<Product>.unmodifiable(_allProducts);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import 'shrine_types.dart';
|
||||
|
||||
const double unitSize = kToolbarHeight;
|
||||
|
||||
final List<Product> _products = new List<Product>.from(allProducts());
|
||||
final List<Product> _products = List<Product>.from(allProducts());
|
||||
final Map<Product, Order> _shoppingCart = <Product, Order>{};
|
||||
|
||||
const int _childrenPerBlock = 8;
|
||||
@@ -75,7 +75,7 @@ class _ShrineGridLayout extends SliverGridLayout {
|
||||
final int row = _rowAtIndex(index);
|
||||
final int column = _columnAtIndex(index);
|
||||
final int columnSpan = _columnSpanAtIndex(index);
|
||||
return new SliverGridGeometry(
|
||||
return SliverGridGeometry(
|
||||
scrollOffset: row * rowStride,
|
||||
crossAxisOffset: column * columnStride,
|
||||
mainAxisExtent: tileHeight,
|
||||
@@ -100,7 +100,7 @@ class _ShrineGridDelegate extends SliverGridDelegate {
|
||||
SliverGridLayout getLayout(SliverConstraints constraints) {
|
||||
final double tileWidth = (constraints.crossAxisExtent - _spacing) / 2.0;
|
||||
const double tileHeight = 40.0 + 144.0 + 40.0;
|
||||
return new _ShrineGridLayout(
|
||||
return _ShrineGridLayout(
|
||||
tileWidth: tileWidth,
|
||||
tileHeight: tileHeight,
|
||||
rowStride: tileHeight + _spacing,
|
||||
@@ -122,15 +122,15 @@ class _VendorItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new SizedBox(
|
||||
return SizedBox(
|
||||
height: 24.0,
|
||||
child: new Row(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new SizedBox(
|
||||
SizedBox(
|
||||
width: 24.0,
|
||||
child: new ClipRRect(
|
||||
borderRadius: new BorderRadius.circular(12.0),
|
||||
child: new Image.asset(
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
child: Image.asset(
|
||||
vendor.avatarAsset,
|
||||
package: vendor.avatarAssetPackage,
|
||||
fit: BoxFit.cover,
|
||||
@@ -138,8 +138,8 @@ class _VendorItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8.0),
|
||||
new Expanded(
|
||||
child: new Text(vendor.name, style: ShrineTheme.of(context).vendorItemStyle),
|
||||
Expanded(
|
||||
child: Text(vendor.name, style: ShrineTheme.of(context).vendorItemStyle),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -159,12 +159,12 @@ abstract class _PriceItem extends StatelessWidget {
|
||||
Widget buildItem(BuildContext context, TextStyle style, EdgeInsets padding) {
|
||||
BoxDecoration decoration;
|
||||
if (_shoppingCart[product] != null)
|
||||
decoration = new BoxDecoration(color: ShrineTheme.of(context).priceHighlightColor);
|
||||
decoration = BoxDecoration(color: ShrineTheme.of(context).priceHighlightColor);
|
||||
|
||||
return new Container(
|
||||
return Container(
|
||||
padding: padding,
|
||||
decoration: decoration,
|
||||
child: new Text(product.priceString, style: style),
|
||||
child: Text(product.priceString, style: style),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -206,34 +206,34 @@ class _HeadingLayout extends MultiChildLayoutDelegate {
|
||||
|
||||
@override
|
||||
void performLayout(Size size) {
|
||||
final Size priceSize = layoutChild(price, new BoxConstraints.loose(size));
|
||||
positionChild(price, new Offset(size.width - priceSize.width, 0.0));
|
||||
final Size priceSize = layoutChild(price, BoxConstraints.loose(size));
|
||||
positionChild(price, Offset(size.width - priceSize.width, 0.0));
|
||||
|
||||
final double halfWidth = size.width / 2.0;
|
||||
final double halfHeight = size.height / 2.0;
|
||||
const double halfUnit = unitSize / 2.0;
|
||||
const double margin = 16.0;
|
||||
|
||||
final Size imageSize = layoutChild(image, new BoxConstraints.loose(size));
|
||||
final Size imageSize = layoutChild(image, BoxConstraints.loose(size));
|
||||
final double imageX = imageSize.width < halfWidth - halfUnit
|
||||
? halfWidth / 2.0 - imageSize.width / 2.0 - halfUnit
|
||||
: halfWidth - imageSize.width;
|
||||
positionChild(image, new Offset(imageX, halfHeight - imageSize.height / 2.0));
|
||||
positionChild(image, Offset(imageX, halfHeight - imageSize.height / 2.0));
|
||||
|
||||
final double maxTitleWidth = halfWidth + unitSize - margin;
|
||||
final BoxConstraints titleBoxConstraints = new BoxConstraints(maxWidth: maxTitleWidth);
|
||||
final BoxConstraints titleBoxConstraints = BoxConstraints(maxWidth: maxTitleWidth);
|
||||
final Size titleSize = layoutChild(title, titleBoxConstraints);
|
||||
final double titleX = halfWidth - unitSize;
|
||||
final double titleY = halfHeight - titleSize.height;
|
||||
positionChild(title, new Offset(titleX, titleY));
|
||||
positionChild(title, Offset(titleX, titleY));
|
||||
|
||||
final Size descriptionSize = layoutChild(description, titleBoxConstraints);
|
||||
final double descriptionY = titleY + titleSize.height + margin;
|
||||
positionChild(description, new Offset(titleX, descriptionY));
|
||||
positionChild(description, Offset(titleX, descriptionY));
|
||||
|
||||
layoutChild(vendor, titleBoxConstraints);
|
||||
final double vendorY = descriptionY + descriptionSize.height + margin;
|
||||
positionChild(vendor, new Offset(titleX, vendorY));
|
||||
positionChild(vendor, Offset(titleX, vendorY));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -254,42 +254,42 @@ class _Heading extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final Size screenSize = MediaQuery.of(context).size;
|
||||
final ShrineTheme theme = ShrineTheme.of(context);
|
||||
return new MergeSemantics(
|
||||
child: new SizedBox(
|
||||
return MergeSemantics(
|
||||
child: SizedBox(
|
||||
height: screenSize.width > screenSize.height
|
||||
? (screenSize.height - kToolbarHeight) * 0.85
|
||||
: (screenSize.height - kToolbarHeight) * 0.70,
|
||||
child: new Container(
|
||||
decoration: new BoxDecoration(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.cardBackgroundColor,
|
||||
border: new Border(bottom: new BorderSide(color: theme.dividerColor)),
|
||||
border: Border(bottom: BorderSide(color: theme.dividerColor)),
|
||||
),
|
||||
child: new CustomMultiChildLayout(
|
||||
delegate: new _HeadingLayout(),
|
||||
child: CustomMultiChildLayout(
|
||||
delegate: _HeadingLayout(),
|
||||
children: <Widget>[
|
||||
new LayoutId(
|
||||
LayoutId(
|
||||
id: _HeadingLayout.price,
|
||||
child: new _FeaturePriceItem(product: product),
|
||||
child: _FeaturePriceItem(product: product),
|
||||
),
|
||||
new LayoutId(
|
||||
LayoutId(
|
||||
id: _HeadingLayout.image,
|
||||
child: new Image.asset(
|
||||
child: Image.asset(
|
||||
product.imageAsset,
|
||||
package: product.imageAssetPackage,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
new LayoutId(
|
||||
LayoutId(
|
||||
id: _HeadingLayout.title,
|
||||
child: new Text(product.featureTitle, style: theme.featureTitleStyle),
|
||||
child: Text(product.featureTitle, style: theme.featureTitleStyle),
|
||||
),
|
||||
new LayoutId(
|
||||
LayoutId(
|
||||
id: _HeadingLayout.description,
|
||||
child: new Text(product.featureDescription, style: theme.featureStyle),
|
||||
child: Text(product.featureDescription, style: theme.featureStyle),
|
||||
),
|
||||
new LayoutId(
|
||||
LayoutId(
|
||||
id: _HeadingLayout.vendor,
|
||||
child: new _VendorItem(vendor: product.vendor),
|
||||
child: _VendorItem(vendor: product.vendor),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -311,38 +311,38 @@ class _ProductItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MergeSemantics(
|
||||
child: new Card(
|
||||
child: new Stack(
|
||||
return MergeSemantics(
|
||||
child: Card(
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
new Column(
|
||||
Column(
|
||||
children: <Widget>[
|
||||
new Align(
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: new _ProductPriceItem(product: product),
|
||||
child: _ProductPriceItem(product: product),
|
||||
),
|
||||
new Container(
|
||||
Container(
|
||||
width: 144.0,
|
||||
height: 144.0,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: new Hero(
|
||||
child: Hero(
|
||||
tag: product.tag,
|
||||
child: new Image.asset(
|
||||
child: Image.asset(
|
||||
product.imageAsset,
|
||||
package: product.imageAssetPackage,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: new _VendorItem(vendor: product.vendor),
|
||||
child: _VendorItem(vendor: product.vendor),
|
||||
),
|
||||
],
|
||||
),
|
||||
new Material(
|
||||
Material(
|
||||
type: MaterialType.transparency,
|
||||
child: new InkWell(onTap: onPressed),
|
||||
child: InkWell(onTap: onPressed),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -355,19 +355,19 @@ class _ProductItem extends StatelessWidget {
|
||||
// of the product items.
|
||||
class ShrineHome extends StatefulWidget {
|
||||
@override
|
||||
_ShrineHomeState createState() => new _ShrineHomeState();
|
||||
_ShrineHomeState createState() => _ShrineHomeState();
|
||||
}
|
||||
|
||||
class _ShrineHomeState extends State<ShrineHome> {
|
||||
static final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(debugLabel: 'Shrine Home');
|
||||
static final _ShrineGridDelegate gridDelegate = new _ShrineGridDelegate();
|
||||
static final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(debugLabel: 'Shrine Home');
|
||||
static final _ShrineGridDelegate gridDelegate = _ShrineGridDelegate();
|
||||
|
||||
Future<Null> _showOrderPage(Product product) async {
|
||||
final Order order = _shoppingCart[product] ?? new Order(product: product);
|
||||
final Order completedOrder = await Navigator.push(context, new ShrineOrderRoute(
|
||||
final Order order = _shoppingCart[product] ?? Order(product: product);
|
||||
final Order completedOrder = await Navigator.push(context, ShrineOrderRoute(
|
||||
order: order,
|
||||
builder: (BuildContext context) {
|
||||
return new OrderPage(
|
||||
return OrderPage(
|
||||
order: order,
|
||||
products: _products,
|
||||
shoppingCart: _shoppingCart,
|
||||
@@ -382,21 +382,21 @@ class _ShrineHomeState extends State<ShrineHome> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Product featured = _products.firstWhere((Product product) => product.featureDescription != null);
|
||||
return new ShrinePage(
|
||||
return ShrinePage(
|
||||
scaffoldKey: _scaffoldKey,
|
||||
products: _products,
|
||||
shoppingCart: _shoppingCart,
|
||||
body: new CustomScrollView(
|
||||
body: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
new SliverToBoxAdapter(child: new _Heading(product: featured)),
|
||||
new SliverSafeArea(
|
||||
SliverToBoxAdapter(child: _Heading(product: featured)),
|
||||
SliverSafeArea(
|
||||
top: false,
|
||||
minimum: const EdgeInsets.all(16.0),
|
||||
sliver: new SliverGrid(
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: gridDelegate,
|
||||
delegate: new SliverChildListDelegate(
|
||||
delegate: SliverChildListDelegate(
|
||||
_products.map((Product product) {
|
||||
return new _ProductItem(
|
||||
return _ProductItem(
|
||||
product: product,
|
||||
onPressed: () { _showOrderPage(product); },
|
||||
);
|
||||
|
||||
@@ -28,30 +28,30 @@ class _ProductItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ShrineTheme theme = ShrineTheme.of(context);
|
||||
return new Column(
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
new Text(product.name, style: theme.featureTitleStyle),
|
||||
Text(product.name, style: theme.featureTitleStyle),
|
||||
const SizedBox(height: 24.0),
|
||||
new Text(product.description, style: theme.featureStyle),
|
||||
Text(product.description, style: theme.featureStyle),
|
||||
const SizedBox(height: 16.0),
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0, right: 88.0),
|
||||
child: new DropdownButtonHideUnderline(
|
||||
child: new Container(
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border.all(
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: const Color(0xFFD9D9D9),
|
||||
),
|
||||
),
|
||||
child: new DropdownButton<int>(
|
||||
child: DropdownButton<int>(
|
||||
items: <int>[0, 1, 2, 3, 4, 5].map((int value) {
|
||||
return new DropdownMenuItem<int>(
|
||||
return DropdownMenuItem<int>(
|
||||
value: value,
|
||||
child: new Padding(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text('Quantity $value', style: theme.quantityMenuStyle),
|
||||
child: Text('Quantity $value', style: theme.quantityMenuStyle),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
@@ -77,19 +77,19 @@ class _VendorItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ShrineTheme theme = ShrineTheme.of(context);
|
||||
return new Column(
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
new SizedBox(
|
||||
SizedBox(
|
||||
height: 24.0,
|
||||
child: new Align(
|
||||
child: Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: new Text(vendor.name, style: theme.vendorTitleStyle),
|
||||
child: Text(vendor.name, style: theme.vendorTitleStyle),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
new Text(vendor.description, style: theme.vendorStyle),
|
||||
Text(vendor.description, style: theme.vendorStyle),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -110,26 +110,26 @@ class _HeadingLayout extends MultiChildLayoutDelegate {
|
||||
const double margin = 56.0;
|
||||
final bool landscape = size.width > size.height;
|
||||
final double imageWidth = (landscape ? size.width / 2.0 : size.width) - margin * 2.0;
|
||||
final BoxConstraints imageConstraints = new BoxConstraints(maxHeight: 224.0, maxWidth: imageWidth);
|
||||
final BoxConstraints imageConstraints = BoxConstraints(maxHeight: 224.0, maxWidth: imageWidth);
|
||||
final Size imageSize = layoutChild(image, imageConstraints);
|
||||
const double imageY = 0.0;
|
||||
positionChild(image, const Offset(margin, imageY));
|
||||
|
||||
final double productWidth = landscape ? size.width / 2.0 : size.width - margin;
|
||||
final BoxConstraints productConstraints = new BoxConstraints(maxWidth: productWidth);
|
||||
final BoxConstraints productConstraints = BoxConstraints(maxWidth: productWidth);
|
||||
final Size productSize = layoutChild(product, productConstraints);
|
||||
final double productX = landscape ? size.width / 2.0 : margin;
|
||||
final double productY = landscape ? 0.0 : imageY + imageSize.height + 16.0;
|
||||
positionChild(product, new Offset(productX, productY));
|
||||
positionChild(product, Offset(productX, productY));
|
||||
|
||||
final Size iconSize = layoutChild(icon, new BoxConstraints.loose(size));
|
||||
positionChild(icon, new Offset(productX - iconSize.width - 16.0, productY + 8.0));
|
||||
final Size iconSize = layoutChild(icon, BoxConstraints.loose(size));
|
||||
positionChild(icon, Offset(productX - iconSize.width - 16.0, productY + 8.0));
|
||||
|
||||
final double vendorWidth = landscape ? size.width - margin : productWidth;
|
||||
layoutChild(vendor, new BoxConstraints(maxWidth: vendorWidth));
|
||||
layoutChild(vendor, BoxConstraints(maxWidth: vendorWidth));
|
||||
final double vendorX = landscape ? margin : productX;
|
||||
final double vendorY = productY + productSize.height + 16.0;
|
||||
positionChild(vendor, new Offset(vendorX, vendorY));
|
||||
positionChild(vendor, Offset(vendorX, vendorY));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -155,21 +155,21 @@ class _Heading extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Size screenSize = MediaQuery.of(context).size;
|
||||
return new SizedBox(
|
||||
return SizedBox(
|
||||
height: (screenSize.height - kToolbarHeight) * 1.35,
|
||||
child: new Material(
|
||||
child: Material(
|
||||
type: MaterialType.card,
|
||||
elevation: 0.0,
|
||||
child: new Padding(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 16.0, top: 18.0, right: 16.0, bottom: 24.0),
|
||||
child: new CustomMultiChildLayout(
|
||||
delegate: new _HeadingLayout(),
|
||||
child: CustomMultiChildLayout(
|
||||
delegate: _HeadingLayout(),
|
||||
children: <Widget>[
|
||||
new LayoutId(
|
||||
LayoutId(
|
||||
id: _HeadingLayout.image,
|
||||
child: new Hero(
|
||||
child: Hero(
|
||||
tag: product.tag,
|
||||
child: new Image.asset(
|
||||
child: Image.asset(
|
||||
product.imageAsset,
|
||||
package: product.imageAssetPackage,
|
||||
fit: BoxFit.contain,
|
||||
@@ -177,7 +177,7 @@ class _Heading extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
new LayoutId(
|
||||
LayoutId(
|
||||
id: _HeadingLayout.icon,
|
||||
child: const Icon(
|
||||
Icons.info_outline,
|
||||
@@ -185,17 +185,17 @@ class _Heading extends StatelessWidget {
|
||||
color: Color(0xFFFFE0E0),
|
||||
),
|
||||
),
|
||||
new LayoutId(
|
||||
LayoutId(
|
||||
id: _HeadingLayout.product,
|
||||
child: new _ProductItem(
|
||||
child: _ProductItem(
|
||||
product: product,
|
||||
quantity: quantity,
|
||||
onChanged: quantityChanged,
|
||||
),
|
||||
),
|
||||
new LayoutId(
|
||||
LayoutId(
|
||||
id: _HeadingLayout.vendor,
|
||||
child: new _VendorItem(vendor: product.vendor),
|
||||
child: _VendorItem(vendor: product.vendor),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -221,7 +221,7 @@ class OrderPage extends StatefulWidget {
|
||||
final Map<Product, Order> shoppingCart;
|
||||
|
||||
@override
|
||||
_OrderPageState createState() => new _OrderPageState();
|
||||
_OrderPageState createState() => _OrderPageState();
|
||||
}
|
||||
|
||||
// Displays a product's heading above photos of all of the other products
|
||||
@@ -233,7 +233,7 @@ class _OrderPageState extends State<OrderPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
scaffoldKey = new GlobalKey<ScaffoldState>(debugLabel: 'Shrine Order ${widget.order}');
|
||||
scaffoldKey = GlobalKey<ScaffoldState>(debugLabel: 'Shrine Order ${widget.order}');
|
||||
}
|
||||
|
||||
Order get currentOrder => ShrineOrderRoute.of(context).order;
|
||||
@@ -253,16 +253,16 @@ class _OrderPageState extends State<OrderPage> {
|
||||
}
|
||||
|
||||
void showSnackBarMessage(String message) {
|
||||
scaffoldKey.currentState.showSnackBar(new SnackBar(content: new Text(message)));
|
||||
scaffoldKey.currentState.showSnackBar(SnackBar(content: Text(message)));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new ShrinePage(
|
||||
return ShrinePage(
|
||||
scaffoldKey: scaffoldKey,
|
||||
products: widget.products,
|
||||
shoppingCart: widget.shoppingCart,
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
updateOrder(inCart: true);
|
||||
final int n = currentOrder.quantity;
|
||||
@@ -277,31 +277,31 @@ class _OrderPageState extends State<OrderPage> {
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
body: new CustomScrollView(
|
||||
body: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
new SliverToBoxAdapter(
|
||||
child: new _Heading(
|
||||
SliverToBoxAdapter(
|
||||
child: _Heading(
|
||||
product: widget.order.product,
|
||||
quantity: currentOrder.quantity,
|
||||
quantityChanged: (int value) { updateOrder(quantity: value); },
|
||||
),
|
||||
),
|
||||
new SliverSafeArea(
|
||||
SliverSafeArea(
|
||||
top: false,
|
||||
minimum: const EdgeInsets.fromLTRB(8.0, 32.0, 8.0, 8.0),
|
||||
sliver: new SliverGrid(
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 248.0,
|
||||
mainAxisSpacing: 8.0,
|
||||
crossAxisSpacing: 8.0,
|
||||
),
|
||||
delegate: new SliverChildListDelegate(
|
||||
delegate: SliverChildListDelegate(
|
||||
widget.products
|
||||
.where((Product product) => product != widget.order.product)
|
||||
.map((Product product) {
|
||||
return new Card(
|
||||
return Card(
|
||||
elevation: 1.0,
|
||||
child: new Image.asset(
|
||||
child: Image.asset(
|
||||
product.imageAsset,
|
||||
package: product.imageAssetPackage,
|
||||
fit: BoxFit.contain,
|
||||
|
||||
@@ -32,7 +32,7 @@ class ShrinePage extends StatefulWidget {
|
||||
final Map<Product, Order> shoppingCart;
|
||||
|
||||
@override
|
||||
ShrinePageState createState() => new ShrinePageState();
|
||||
ShrinePageState createState() => ShrinePageState();
|
||||
}
|
||||
|
||||
/// Defines the Scaffold, AppBar, etc that the demo pages have in common.
|
||||
@@ -57,13 +57,13 @@ class ShrinePageState extends State<ShrinePage> {
|
||||
child: Text('The shopping cart is empty')
|
||||
);
|
||||
}
|
||||
return new ListView(
|
||||
return ListView(
|
||||
padding: kMaterialListPadding,
|
||||
children: widget.shoppingCart.values.map((Order order) {
|
||||
return new ListTile(
|
||||
title: new Text(order.product.name),
|
||||
leading: new Text('${order.quantity}'),
|
||||
subtitle: new Text(order.product.vendor.name)
|
||||
return ListTile(
|
||||
title: Text(order.product.name),
|
||||
leading: Text('${order.quantity}'),
|
||||
subtitle: Text(order.product.vendor.name)
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
@@ -86,29 +86,29 @@ class ShrinePageState extends State<ShrinePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ShrineTheme theme = ShrineTheme.of(context);
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: widget.scaffoldKey,
|
||||
appBar: new AppBar(
|
||||
appBar: AppBar(
|
||||
elevation: _appBarElevation,
|
||||
backgroundColor: theme.appBarBackgroundColor,
|
||||
iconTheme: Theme.of(context).iconTheme,
|
||||
brightness: Brightness.light,
|
||||
flexibleSpace: new Container(
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border(
|
||||
bottom: new BorderSide(color: theme.dividerColor)
|
||||
flexibleSpace: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: theme.dividerColor)
|
||||
)
|
||||
)
|
||||
),
|
||||
title: new Text('SHRINE', style: ShrineTheme.of(context).appBarTitleStyle),
|
||||
title: Text('SHRINE', style: ShrineTheme.of(context).appBarTitleStyle),
|
||||
centerTitle: true,
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.shopping_cart),
|
||||
tooltip: 'Shopping cart',
|
||||
onPressed: _showShoppingCart
|
||||
),
|
||||
new PopupMenuButton<ShrineAction>(
|
||||
PopupMenuButton<ShrineAction>(
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<ShrineAction>>[
|
||||
const PopupMenuItem<ShrineAction>(
|
||||
value: ShrineAction.sortByPrice,
|
||||
@@ -140,7 +140,7 @@ class ShrinePageState extends State<ShrinePage> {
|
||||
]
|
||||
),
|
||||
floatingActionButton: widget.floatingActionButton,
|
||||
body: new NotificationListener<ScrollNotification>(
|
||||
body: NotificationListener<ScrollNotification>(
|
||||
onNotification: _handleScrollNotification,
|
||||
child: widget.body
|
||||
)
|
||||
|
||||
@@ -12,15 +12,15 @@ class ShrineStyle extends TextStyle {
|
||||
: super(inherit: false, color: color, fontFamily: 'AbrilFatface', fontSize: size, fontWeight: weight, textBaseline: TextBaseline.alphabetic);
|
||||
}
|
||||
|
||||
TextStyle robotoRegular12(Color color) => new ShrineStyle.roboto(12.0, FontWeight.w500, color);
|
||||
TextStyle robotoLight12(Color color) => new ShrineStyle.roboto(12.0, FontWeight.w300, color);
|
||||
TextStyle robotoRegular14(Color color) => new ShrineStyle.roboto(14.0, FontWeight.w500, color);
|
||||
TextStyle robotoMedium14(Color color) => new ShrineStyle.roboto(14.0, FontWeight.w600, color);
|
||||
TextStyle robotoLight14(Color color) => new ShrineStyle.roboto(14.0, FontWeight.w300, color);
|
||||
TextStyle robotoRegular16(Color color) => new ShrineStyle.roboto(16.0, FontWeight.w500, color);
|
||||
TextStyle robotoRegular20(Color color) => new ShrineStyle.roboto(20.0, FontWeight.w500, color);
|
||||
TextStyle abrilFatfaceRegular24(Color color) => new ShrineStyle.abrilFatface(24.0, FontWeight.w500, color);
|
||||
TextStyle abrilFatfaceRegular34(Color color) => new ShrineStyle.abrilFatface(34.0, FontWeight.w500, color);
|
||||
TextStyle robotoRegular12(Color color) => ShrineStyle.roboto(12.0, FontWeight.w500, color);
|
||||
TextStyle robotoLight12(Color color) => ShrineStyle.roboto(12.0, FontWeight.w300, color);
|
||||
TextStyle robotoRegular14(Color color) => ShrineStyle.roboto(14.0, FontWeight.w500, color);
|
||||
TextStyle robotoMedium14(Color color) => ShrineStyle.roboto(14.0, FontWeight.w600, color);
|
||||
TextStyle robotoLight14(Color color) => ShrineStyle.roboto(14.0, FontWeight.w300, color);
|
||||
TextStyle robotoRegular16(Color color) => ShrineStyle.roboto(16.0, FontWeight.w500, color);
|
||||
TextStyle robotoRegular20(Color color) => ShrineStyle.roboto(20.0, FontWeight.w500, color);
|
||||
TextStyle abrilFatfaceRegular24(Color color) => ShrineStyle.abrilFatface(24.0, FontWeight.w500, color);
|
||||
TextStyle abrilFatfaceRegular34(Color color) => ShrineStyle.abrilFatface(34.0, FontWeight.w500, color);
|
||||
|
||||
/// The TextStyles and Colors used for titles, labels, and descriptions. This
|
||||
/// InheritedWidget is shared by all of the routes and widgets created for
|
||||
|
||||
@@ -80,7 +80,7 @@ class Order {
|
||||
final bool inCart;
|
||||
|
||||
Order copyWith({ Product product, int quantity, bool inCart }) {
|
||||
return new Order(
|
||||
return Order(
|
||||
product: product ?? this.product,
|
||||
quantity: quantity ?? this.quantity,
|
||||
inCart: inCart ?? this.inCart
|
||||
|
||||
@@ -11,13 +11,13 @@ import 'shrine/shrine_theme.dart' show ShrineTheme;
|
||||
// used by the ShrineDemo and by each route pushed from there because this
|
||||
// isn't a standalone app with its own main() and MaterialApp.
|
||||
Widget buildShrine(BuildContext context, Widget child) {
|
||||
return new Theme(
|
||||
data: new ThemeData(
|
||||
return Theme(
|
||||
data: ThemeData(
|
||||
primarySwatch: Colors.grey,
|
||||
iconTheme: const IconThemeData(color: Color(0xFF707070)),
|
||||
platform: Theme.of(context).platform,
|
||||
),
|
||||
child: new ShrineTheme(child: child)
|
||||
child: ShrineTheme(child: child)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -38,5 +38,5 @@ class ShrineDemo extends StatelessWidget {
|
||||
static const String routeName = '/shrine'; // Used by the Gallery app.
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => buildShrine(context, new ShrineHome());
|
||||
Widget build(BuildContext context) => buildShrine(context, ShrineHome());
|
||||
}
|
||||
|
||||
@@ -23,17 +23,17 @@ class TextStyleItem extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final TextStyle nameStyle = theme.textTheme.caption.copyWith(color: theme.textTheme.caption.color);
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 16.0),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new SizedBox(
|
||||
SizedBox(
|
||||
width: 72.0,
|
||||
child: new Text(name, style: nameStyle)
|
||||
child: Text(name, style: nameStyle)
|
||||
),
|
||||
new Expanded(
|
||||
child: new Text(text, style: style.copyWith(height: 1.0))
|
||||
Expanded(
|
||||
child: Text(text, style: style.copyWith(height: 1.0))
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -48,32 +48,32 @@ class TypographyDemo extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final TextTheme textTheme = Theme.of(context).textTheme;
|
||||
final List<Widget> styleItems = <Widget>[
|
||||
new TextStyleItem(name: 'Display 3', style: textTheme.display3, text: 'Regular 56sp'),
|
||||
new TextStyleItem(name: 'Display 2', style: textTheme.display2, text: 'Regular 45sp'),
|
||||
new TextStyleItem(name: 'Display 1', style: textTheme.display1, text: 'Regular 34sp'),
|
||||
new TextStyleItem(name: 'Headline', style: textTheme.headline, text: 'Regular 24sp'),
|
||||
new TextStyleItem(name: 'Title', style: textTheme.title, text: 'Medium 20sp'),
|
||||
new TextStyleItem(name: 'Subheading', style: textTheme.subhead, text: 'Regular 16sp'),
|
||||
new TextStyleItem(name: 'Body 2', style: textTheme.body2, text: 'Medium 14sp'),
|
||||
new TextStyleItem(name: 'Body 1', style: textTheme.body1, text: 'Regular 14sp'),
|
||||
new TextStyleItem(name: 'Caption', style: textTheme.caption, text: 'Regular 12sp'),
|
||||
new TextStyleItem(name: 'Button', style: textTheme.button, text: 'MEDIUM (ALL CAPS) 14sp')
|
||||
TextStyleItem(name: 'Display 3', style: textTheme.display3, text: 'Regular 56sp'),
|
||||
TextStyleItem(name: 'Display 2', style: textTheme.display2, text: 'Regular 45sp'),
|
||||
TextStyleItem(name: 'Display 1', style: textTheme.display1, text: 'Regular 34sp'),
|
||||
TextStyleItem(name: 'Headline', style: textTheme.headline, text: 'Regular 24sp'),
|
||||
TextStyleItem(name: 'Title', style: textTheme.title, text: 'Medium 20sp'),
|
||||
TextStyleItem(name: 'Subheading', style: textTheme.subhead, text: 'Regular 16sp'),
|
||||
TextStyleItem(name: 'Body 2', style: textTheme.body2, text: 'Medium 14sp'),
|
||||
TextStyleItem(name: 'Body 1', style: textTheme.body1, text: 'Regular 14sp'),
|
||||
TextStyleItem(name: 'Caption', style: textTheme.caption, text: 'Regular 12sp'),
|
||||
TextStyleItem(name: 'Button', style: textTheme.button, text: 'MEDIUM (ALL CAPS) 14sp')
|
||||
];
|
||||
|
||||
if (MediaQuery.of(context).size.width > 500.0) {
|
||||
styleItems.insert(0, new TextStyleItem(
|
||||
styleItems.insert(0, TextStyleItem(
|
||||
name: 'Display 4',
|
||||
style: textTheme.display4,
|
||||
text: 'Light 112sp'
|
||||
));
|
||||
}
|
||||
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: const Text('Typography')),
|
||||
body: new SafeArea(
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Typography')),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new ListView(children: styleItems),
|
||||
child: ListView(children: styleItems),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ class VideoCard extends StatelessWidget {
|
||||
: super(key: key);
|
||||
|
||||
Widget _buildInlineVideo() {
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 30.0),
|
||||
child: new Center(
|
||||
child: new AspectRatio(
|
||||
child: Center(
|
||||
child: AspectRatio(
|
||||
aspectRatio: 3 / 2,
|
||||
child: new Hero(
|
||||
child: Hero(
|
||||
tag: controller,
|
||||
child: new VideoPlayerLoading(controller),
|
||||
child: VideoPlayerLoading(controller),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -37,16 +37,16 @@ class VideoCard extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildFullScreenVideo() {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text(title),
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
),
|
||||
body: new Center(
|
||||
child: new AspectRatio(
|
||||
body: Center(
|
||||
child: AspectRatio(
|
||||
aspectRatio: 3 / 2,
|
||||
child: new Hero(
|
||||
child: Hero(
|
||||
tag: controller,
|
||||
child: new VideoPlayPause(controller),
|
||||
child: VideoPlayPause(controller),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -61,8 +61,8 @@ class VideoCard extends StatelessWidget {
|
||||
}
|
||||
|
||||
void pushFullScreenWidget() {
|
||||
final TransitionRoute<void> route = new PageRouteBuilder<void>(
|
||||
settings: new RouteSettings(name: title, isInitialRoute: false),
|
||||
final TransitionRoute<void> route = PageRouteBuilder<void>(
|
||||
settings: RouteSettings(name: title, isInitialRoute: false),
|
||||
pageBuilder: fullScreenRoutePageBuilder,
|
||||
);
|
||||
|
||||
@@ -74,14 +74,14 @@ class VideoCard extends StatelessWidget {
|
||||
Navigator.of(context).push(route);
|
||||
}
|
||||
|
||||
return new SafeArea(
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Card(
|
||||
child: new Column(
|
||||
child: Card(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new ListTile(title: new Text(title), subtitle: new Text(subtitle)),
|
||||
new GestureDetector(
|
||||
ListTile(title: Text(title), subtitle: Text(subtitle)),
|
||||
GestureDetector(
|
||||
onTap: pushFullScreenWidget,
|
||||
child: _buildInlineVideo(),
|
||||
),
|
||||
@@ -98,7 +98,7 @@ class VideoPlayerLoading extends StatefulWidget {
|
||||
const VideoPlayerLoading(this.controller);
|
||||
|
||||
@override
|
||||
_VideoPlayerLoadingState createState() => new _VideoPlayerLoadingState();
|
||||
_VideoPlayerLoadingState createState() => _VideoPlayerLoadingState();
|
||||
}
|
||||
|
||||
class _VideoPlayerLoadingState extends State<VideoPlayerLoading> {
|
||||
@@ -124,11 +124,11 @@ class _VideoPlayerLoadingState extends State<VideoPlayerLoading> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_initialized) {
|
||||
return new VideoPlayer(widget.controller);
|
||||
return VideoPlayer(widget.controller);
|
||||
}
|
||||
return new Stack(
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
new VideoPlayer(widget.controller),
|
||||
VideoPlayer(widget.controller),
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
],
|
||||
fit: StackFit.expand,
|
||||
@@ -142,7 +142,7 @@ class VideoPlayPause extends StatefulWidget {
|
||||
const VideoPlayPause(this.controller);
|
||||
|
||||
@override
|
||||
State createState() => new _VideoPlayPauseState();
|
||||
State createState() => _VideoPlayPauseState();
|
||||
}
|
||||
|
||||
class _VideoPlayPauseState extends State<VideoPlayPause> {
|
||||
@@ -172,12 +172,12 @@ class _VideoPlayPauseState extends State<VideoPlayPause> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Stack(
|
||||
return Stack(
|
||||
alignment: Alignment.bottomCenter,
|
||||
fit: StackFit.expand,
|
||||
children: <Widget>[
|
||||
new GestureDetector(
|
||||
child: new VideoPlayerLoading(controller),
|
||||
GestureDetector(
|
||||
child: VideoPlayerLoading(controller),
|
||||
onTap: () {
|
||||
if (!controller.value.initialized) {
|
||||
return;
|
||||
@@ -195,7 +195,7 @@ class _VideoPlayPauseState extends State<VideoPlayPause> {
|
||||
}
|
||||
},
|
||||
),
|
||||
new Center(child: imageFadeAnimation),
|
||||
Center(child: imageFadeAnimation),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -211,7 +211,7 @@ class FadeAnimation extends StatefulWidget {
|
||||
});
|
||||
|
||||
@override
|
||||
_FadeAnimationState createState() => new _FadeAnimationState();
|
||||
_FadeAnimationState createState() => _FadeAnimationState();
|
||||
}
|
||||
|
||||
class _FadeAnimationState extends State<FadeAnimation>
|
||||
@@ -221,7 +221,7 @@ class _FadeAnimationState extends State<FadeAnimation>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
animationController = new AnimationController(
|
||||
animationController = AnimationController(
|
||||
duration: widget.duration,
|
||||
vsync: this,
|
||||
);
|
||||
@@ -256,11 +256,11 @@ class _FadeAnimationState extends State<FadeAnimation>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return animationController.isAnimating
|
||||
? new Opacity(
|
||||
? Opacity(
|
||||
opacity: 1.0 - animationController.value,
|
||||
child: widget.child,
|
||||
)
|
||||
: new Container();
|
||||
: Container();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ class ConnectivityOverlay extends StatefulWidget {
|
||||
});
|
||||
|
||||
@override
|
||||
_ConnectivityOverlayState createState() => new _ConnectivityOverlayState();
|
||||
_ConnectivityOverlayState createState() => _ConnectivityOverlayState();
|
||||
}
|
||||
|
||||
class _ConnectivityOverlayState extends State<ConnectivityOverlay> {
|
||||
@@ -294,7 +294,7 @@ class _ConnectivityOverlayState extends State<ConnectivityOverlay> {
|
||||
);
|
||||
|
||||
Stream<ConnectivityResult> connectivityStream() async* {
|
||||
final Connectivity connectivity = new Connectivity();
|
||||
final Connectivity connectivity = Connectivity();
|
||||
ConnectivityResult previousResult = await connectivity.checkConnectivity();
|
||||
yield previousResult;
|
||||
await for (ConnectivityResult result
|
||||
@@ -341,10 +341,10 @@ class VideoDemo extends StatefulWidget {
|
||||
static const String routeName = '/video';
|
||||
|
||||
@override
|
||||
_VideoDemoState createState() => new _VideoDemoState();
|
||||
_VideoDemoState createState() => _VideoDemoState();
|
||||
}
|
||||
|
||||
final DeviceInfoPlugin deviceInfoPlugin = new DeviceInfoPlugin();
|
||||
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
||||
|
||||
Future<bool> isIOSSimulator() async {
|
||||
return Platform.isIOS && !(await deviceInfoPlugin.iosInfo).isPhysicalDevice;
|
||||
@@ -353,16 +353,16 @@ Future<bool> isIOSSimulator() async {
|
||||
class _VideoDemoState extends State<VideoDemo>
|
||||
with SingleTickerProviderStateMixin {
|
||||
final VideoPlayerController butterflyController =
|
||||
new VideoPlayerController.asset(
|
||||
VideoPlayerController.asset(
|
||||
'videos/butterfly.mp4',
|
||||
package: 'flutter_gallery_assets',
|
||||
);
|
||||
final VideoPlayerController beeController = new VideoPlayerController.network(
|
||||
final VideoPlayerController beeController = VideoPlayerController.network(
|
||||
beeUri,
|
||||
);
|
||||
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final Completer<Null> connectedCompleter = new Completer<Null>();
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final Completer<Null> connectedCompleter = Completer<Null>();
|
||||
bool isSupported = true;
|
||||
|
||||
@override
|
||||
@@ -395,21 +395,21 @@ class _VideoDemoState extends State<VideoDemo>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
return Scaffold(
|
||||
key: scaffoldKey,
|
||||
appBar: new AppBar(
|
||||
appBar: AppBar(
|
||||
title: const Text('Videos'),
|
||||
),
|
||||
body: isSupported
|
||||
? new ConnectivityOverlay(
|
||||
child: new ListView(
|
||||
? ConnectivityOverlay(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
new VideoCard(
|
||||
VideoCard(
|
||||
title: 'Butterfly',
|
||||
subtitle: '… flutters by',
|
||||
controller: butterflyController,
|
||||
),
|
||||
new VideoCard(
|
||||
VideoCard(
|
||||
title: 'Bee',
|
||||
subtitle: '… gently buzzing',
|
||||
controller: beeController,
|
||||
|
||||
@@ -26,7 +26,7 @@ class _LinkTextSpan extends TextSpan {
|
||||
_LinkTextSpan({ TextStyle style, String url, String text }) : super(
|
||||
style: style,
|
||||
text: text ?? url,
|
||||
recognizer: new TapGestureRecognizer()..onTap = () {
|
||||
recognizer: TapGestureRecognizer()..onTap = () {
|
||||
launch(url, forceSafariVC: false);
|
||||
}
|
||||
);
|
||||
@@ -43,12 +43,12 @@ void showGalleryAboutDialog(BuildContext context) {
|
||||
applicationIcon: const FlutterLogo(),
|
||||
applicationLegalese: '© 2017 The Chromium Authors',
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 24.0),
|
||||
child: new RichText(
|
||||
text: new TextSpan(
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: <TextSpan>[
|
||||
new TextSpan(
|
||||
TextSpan(
|
||||
style: aboutTextStyle,
|
||||
text: 'Flutter is an early-stage, open-source project to help developers '
|
||||
'build high-performance, high-fidelity, mobile apps for '
|
||||
@@ -57,20 +57,20 @@ void showGalleryAboutDialog(BuildContext context) {
|
||||
"Flutter's many widgets, behaviors, animations, layouts, "
|
||||
'and more. Learn more about Flutter at '
|
||||
),
|
||||
new _LinkTextSpan(
|
||||
_LinkTextSpan(
|
||||
style: linkStyle,
|
||||
url: 'https://flutter.io',
|
||||
),
|
||||
new TextSpan(
|
||||
TextSpan(
|
||||
style: aboutTextStyle,
|
||||
text: '.\n\nTo see the source code for this app, please visit the ',
|
||||
),
|
||||
new _LinkTextSpan(
|
||||
_LinkTextSpan(
|
||||
style: linkStyle,
|
||||
url: 'https://goo.gl/iv1p4G',
|
||||
text: 'flutter github repo',
|
||||
),
|
||||
new TextSpan(
|
||||
TextSpan(
|
||||
style: aboutTextStyle,
|
||||
text: '.',
|
||||
),
|
||||
|
||||
@@ -36,7 +36,7 @@ class GalleryApp extends StatefulWidget {
|
||||
final bool testMode;
|
||||
|
||||
@override
|
||||
_GalleryAppState createState() => new _GalleryAppState();
|
||||
_GalleryAppState createState() => _GalleryAppState();
|
||||
}
|
||||
|
||||
class _GalleryAppState extends State<GalleryApp> {
|
||||
@@ -47,7 +47,7 @@ class _GalleryAppState extends State<GalleryApp> {
|
||||
// For a different example of how to set up an application routing table
|
||||
// using named routes, consider the example in the Navigator class documentation:
|
||||
// https://docs.flutter.io/flutter/widgets/Navigator-class.html
|
||||
return new Map<String, WidgetBuilder>.fromIterable(
|
||||
return Map<String, WidgetBuilder>.fromIterable(
|
||||
kAllGalleryDemos,
|
||||
key: (dynamic demo) => '${demo.routeName}',
|
||||
value: (dynamic demo) => demo.buildRoute,
|
||||
@@ -57,7 +57,7 @@ class _GalleryAppState extends State<GalleryApp> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_options = new GalleryOptions(
|
||||
_options = GalleryOptions(
|
||||
theme: kLightGalleryTheme,
|
||||
textScaleFactor: kAllGalleryTextScaleValues[0],
|
||||
timeDilation: timeDilation,
|
||||
@@ -81,7 +81,7 @@ class _GalleryAppState extends State<GalleryApp> {
|
||||
// We delay the time dilation change long enough that the user can see
|
||||
// that UI has started reacting and then we slam on the brakes so that
|
||||
// they see that the time is in fact now dilated.
|
||||
_timeDilationTimer = new Timer(const Duration(milliseconds: 150), () {
|
||||
_timeDilationTimer = Timer(const Duration(milliseconds: 150), () {
|
||||
timeDilation = newOptions.timeDilation;
|
||||
});
|
||||
} else {
|
||||
@@ -94,9 +94,9 @@ class _GalleryAppState extends State<GalleryApp> {
|
||||
}
|
||||
|
||||
Widget _applyTextScaleFactor(Widget child) {
|
||||
return new Builder(
|
||||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
return new MediaQuery(
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
textScaleFactor: _options.textScaleFactor.scale,
|
||||
),
|
||||
@@ -108,9 +108,9 @@ class _GalleryAppState extends State<GalleryApp> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget home = new GalleryHome(
|
||||
Widget home = GalleryHome(
|
||||
testMode: widget.testMode,
|
||||
optionsPage: new GalleryOptionsPage(
|
||||
optionsPage: GalleryOptionsPage(
|
||||
options: _options,
|
||||
onOptionsChanged: _handleOptionsChanged,
|
||||
onSendFeedback: widget.onSendFeedback ?? () {
|
||||
@@ -120,13 +120,13 @@ class _GalleryAppState extends State<GalleryApp> {
|
||||
);
|
||||
|
||||
if (widget.updateUrlFetcher != null) {
|
||||
home = new Updater(
|
||||
home = Updater(
|
||||
updateUrlFetcher: widget.updateUrlFetcher,
|
||||
child: home,
|
||||
);
|
||||
}
|
||||
|
||||
return new MaterialApp(
|
||||
return MaterialApp(
|
||||
theme: _options.theme.data.copyWith(platform: _options.platform),
|
||||
title: 'Flutter Gallery',
|
||||
color: Colors.grey,
|
||||
@@ -135,7 +135,7 @@ class _GalleryAppState extends State<GalleryApp> {
|
||||
checkerboardRasterCacheImages: _options.showRasterCacheImagesCheckerboard,
|
||||
routes: _buildRoutes(),
|
||||
builder: (BuildContext context, Widget child) {
|
||||
return new Directionality(
|
||||
return Directionality(
|
||||
textDirection: _options.textDirection,
|
||||
child: _applyTextScaleFactor(child),
|
||||
);
|
||||
|
||||
@@ -12,7 +12,7 @@ const double _kFrontClosedHeight = 92.0; // front layer height when closed
|
||||
const double _kBackAppBarHeight = 56.0; // back layer (options) appbar height
|
||||
|
||||
// The size of the front layer heading's left and right beveled corners.
|
||||
final Tween<BorderRadius> _kFrontHeadingBevelRadius = new BorderRadiusTween(
|
||||
final Tween<BorderRadius> _kFrontHeadingBevelRadius = BorderRadiusTween(
|
||||
begin: const BorderRadius.only(
|
||||
topLeft: Radius.circular(12.0),
|
||||
topRight: Radius.circular(12.0),
|
||||
@@ -35,7 +35,7 @@ class _TappableWhileStatusIs extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
_TappableWhileStatusIsState createState() => new _TappableWhileStatusIsState();
|
||||
_TappableWhileStatusIsState createState() => _TappableWhileStatusIsState();
|
||||
}
|
||||
|
||||
class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> {
|
||||
@@ -65,7 +65,7 @@ class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new AbsorbPointer(
|
||||
return AbsorbPointer(
|
||||
absorbing: !_active,
|
||||
child: widget.child,
|
||||
);
|
||||
@@ -89,30 +89,30 @@ class _CrossFadeTransition extends AnimatedWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final Animation<double> progress = listenable;
|
||||
|
||||
final double opacity1 = new CurvedAnimation(
|
||||
parent: new ReverseAnimation(progress),
|
||||
final double opacity1 = CurvedAnimation(
|
||||
parent: ReverseAnimation(progress),
|
||||
curve: const Interval(0.5, 1.0),
|
||||
).value;
|
||||
|
||||
final double opacity2 = new CurvedAnimation(
|
||||
final double opacity2 = CurvedAnimation(
|
||||
parent: progress,
|
||||
curve: const Interval(0.5, 1.0),
|
||||
).value;
|
||||
|
||||
return new Stack(
|
||||
return Stack(
|
||||
alignment: alignment,
|
||||
children: <Widget>[
|
||||
new Opacity(
|
||||
Opacity(
|
||||
opacity: opacity1,
|
||||
child: new Semantics(
|
||||
child: Semantics(
|
||||
scopesRoute: true,
|
||||
explicitChildNodes: true,
|
||||
child: child1,
|
||||
),
|
||||
),
|
||||
new Opacity(
|
||||
Opacity(
|
||||
opacity: opacity2,
|
||||
child: new Semantics(
|
||||
child: Semantics(
|
||||
scopesRoute: true,
|
||||
explicitChildNodes: true,
|
||||
child: child0,
|
||||
@@ -138,19 +138,19 @@ class _BackAppBar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<Widget> children = <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
width: 56.0,
|
||||
child: leading,
|
||||
),
|
||||
new Expanded(
|
||||
Expanded(
|
||||
child: title,
|
||||
),
|
||||
];
|
||||
|
||||
if (trailing != null) {
|
||||
children.add(
|
||||
new Container(
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
width: 56.0,
|
||||
child: trailing,
|
||||
@@ -162,11 +162,11 @@ class _BackAppBar extends StatelessWidget {
|
||||
|
||||
return IconTheme.merge(
|
||||
data: theme.primaryIconTheme,
|
||||
child: new DefaultTextStyle(
|
||||
child: DefaultTextStyle(
|
||||
style: theme.primaryTextTheme.title,
|
||||
child: new SizedBox(
|
||||
child: SizedBox(
|
||||
height: _kBackAppBarHeight,
|
||||
child: new Row(children: children),
|
||||
child: Row(children: children),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -191,26 +191,26 @@ class Backdrop extends StatefulWidget {
|
||||
final Widget backLayer;
|
||||
|
||||
@override
|
||||
_BackdropState createState() => new _BackdropState();
|
||||
_BackdropState createState() => _BackdropState();
|
||||
}
|
||||
|
||||
class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin {
|
||||
final GlobalKey _backdropKey = new GlobalKey(debugLabel: 'Backdrop');
|
||||
final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop');
|
||||
AnimationController _controller;
|
||||
Animation<double> _frontOpacity;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = new AnimationController(
|
||||
_controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
value: 1.0,
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
_frontOpacity =
|
||||
new Tween<double>(begin: 0.2, end: 1.0).animate(
|
||||
new CurvedAnimation(
|
||||
Tween<double>(begin: 0.2, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: const Interval(0.0, 0.4, curve: Curves.easeInOut),
|
||||
),
|
||||
@@ -254,35 +254,35 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
|
||||
}
|
||||
|
||||
Widget _buildStack(BuildContext context, BoxConstraints constraints) {
|
||||
final Animation<RelativeRect> frontRelativeRect = new RelativeRectTween(
|
||||
begin: new RelativeRect.fromLTRB(0.0, constraints.biggest.height - _kFrontClosedHeight, 0.0, 0.0),
|
||||
final Animation<RelativeRect> frontRelativeRect = RelativeRectTween(
|
||||
begin: RelativeRect.fromLTRB(0.0, constraints.biggest.height - _kFrontClosedHeight, 0.0, 0.0),
|
||||
end: const RelativeRect.fromLTRB(0.0, _kBackAppBarHeight, 0.0, 0.0),
|
||||
).animate(_controller);
|
||||
|
||||
final List<Widget> layers = <Widget>[
|
||||
// Back layer
|
||||
new Column(
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
new _BackAppBar(
|
||||
_BackAppBar(
|
||||
leading: widget.frontAction,
|
||||
title: new _CrossFadeTransition(
|
||||
title: _CrossFadeTransition(
|
||||
progress: _controller,
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child0: new Semantics(namesRoute: true, child: widget.frontTitle),
|
||||
child1: new Semantics(namesRoute: true, child: widget.backTitle),
|
||||
child0: Semantics(namesRoute: true, child: widget.frontTitle),
|
||||
child1: Semantics(namesRoute: true, child: widget.backTitle),
|
||||
),
|
||||
trailing: new IconButton(
|
||||
trailing: IconButton(
|
||||
onPressed: _toggleFrontLayer,
|
||||
tooltip: 'Toggle options page',
|
||||
icon: new AnimatedIcon(
|
||||
icon: AnimatedIcon(
|
||||
icon: AnimatedIcons.close_menu,
|
||||
progress: _controller,
|
||||
),
|
||||
),
|
||||
),
|
||||
new Expanded(
|
||||
child: new Visibility(
|
||||
Expanded(
|
||||
child: Visibility(
|
||||
child: widget.backLayer,
|
||||
visible: _controller.status != AnimationStatus.completed,
|
||||
maintainState: true,
|
||||
@@ -291,16 +291,16 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
|
||||
],
|
||||
),
|
||||
// Front layer
|
||||
new PositionedTransition(
|
||||
PositionedTransition(
|
||||
rect: frontRelativeRect,
|
||||
child: new AnimatedBuilder(
|
||||
child: AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (BuildContext context, Widget child) {
|
||||
return new PhysicalShape(
|
||||
return PhysicalShape(
|
||||
elevation: 12.0,
|
||||
color: Theme.of(context).canvasColor,
|
||||
clipper: new ShapeBorderClipper(
|
||||
shape: new BeveledRectangleBorder(
|
||||
clipper: ShapeBorderClipper(
|
||||
shape: BeveledRectangleBorder(
|
||||
borderRadius: _kFrontHeadingBevelRadius.lerp(_controller.value),
|
||||
),
|
||||
),
|
||||
@@ -308,10 +308,10 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: new _TappableWhileStatusIs(
|
||||
child: _TappableWhileStatusIs(
|
||||
AnimationStatus.completed,
|
||||
controller: _controller,
|
||||
child: new FadeTransition(
|
||||
child: FadeTransition(
|
||||
opacity: _frontOpacity,
|
||||
child: widget.frontLayer,
|
||||
),
|
||||
@@ -326,12 +326,12 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
|
||||
// with a tap. It may obscure part of the front layer's topmost child.
|
||||
if (widget.frontHeading != null) {
|
||||
layers.add(
|
||||
new PositionedTransition(
|
||||
PositionedTransition(
|
||||
rect: frontRelativeRect,
|
||||
child: new ExcludeSemantics(
|
||||
child: new Container(
|
||||
child: ExcludeSemantics(
|
||||
child: Container(
|
||||
alignment: Alignment.topLeft,
|
||||
child: new GestureDetector(
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: _toggleFrontLayer,
|
||||
onVerticalDragUpdate: _handleDragUpdate,
|
||||
@@ -344,7 +344,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
|
||||
);
|
||||
}
|
||||
|
||||
return new Stack(
|
||||
return Stack(
|
||||
key: _backdropKey,
|
||||
children: layers,
|
||||
);
|
||||
@@ -352,6 +352,6 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new LayoutBuilder(builder: _buildStack);
|
||||
return LayoutBuilder(builder: _buildStack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,24 +46,24 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
|
||||
void _showExampleCode(BuildContext context) {
|
||||
final String tag = demos[DefaultTabController.of(context).index].exampleCodeTag;
|
||||
if (tag != null) {
|
||||
Navigator.push(context, new MaterialPageRoute<FullScreenCodeDialog>(
|
||||
builder: (BuildContext context) => new FullScreenCodeDialog(exampleCodeTag: tag)
|
||||
Navigator.push(context, MaterialPageRoute<FullScreenCodeDialog>(
|
||||
builder: (BuildContext context) => FullScreenCodeDialog(exampleCodeTag: tag)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new DefaultTabController(
|
||||
return DefaultTabController(
|
||||
length: demos.length,
|
||||
child: new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text(title),
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
actions: (actions ?? <Widget>[])..addAll(
|
||||
<Widget>[
|
||||
new Builder(
|
||||
Builder(
|
||||
builder: (BuildContext context) {
|
||||
return new IconButton(
|
||||
return IconButton(
|
||||
icon: const Icon(Icons.code),
|
||||
tooltip: 'Show example code',
|
||||
onPressed: () {
|
||||
@@ -74,25 +74,25 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
|
||||
)
|
||||
],
|
||||
),
|
||||
bottom: new TabBar(
|
||||
bottom: TabBar(
|
||||
isScrollable: true,
|
||||
tabs: demos.map((ComponentDemoTabData data) => new Tab(text: data.tabName)).toList(),
|
||||
tabs: demos.map((ComponentDemoTabData data) => Tab(text: data.tabName)).toList(),
|
||||
),
|
||||
),
|
||||
body: new TabBarView(
|
||||
body: TabBarView(
|
||||
children: demos.map((ComponentDemoTabData demo) {
|
||||
return new SafeArea(
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: new Text(demo.description,
|
||||
child: Text(demo.description,
|
||||
style: Theme.of(context).textTheme.subhead
|
||||
)
|
||||
),
|
||||
new Expanded(child: demo.demoWidget)
|
||||
Expanded(child: demo.demoWidget)
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -109,7 +109,7 @@ class FullScreenCodeDialog extends StatefulWidget {
|
||||
final String exampleCodeTag;
|
||||
|
||||
@override
|
||||
FullScreenCodeDialogState createState() => new FullScreenCodeDialogState();
|
||||
FullScreenCodeDialogState createState() => FullScreenCodeDialogState();
|
||||
}
|
||||
|
||||
class FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
|
||||
@@ -140,14 +140,14 @@ class FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
|
||||
child: CircularProgressIndicator()
|
||||
);
|
||||
} else {
|
||||
body = new SingleChildScrollView(
|
||||
child: new Padding(
|
||||
body = SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: new RichText(
|
||||
text: new TextSpan(
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
style: const TextStyle(fontFamily: 'monospace', fontSize: 10.0),
|
||||
children: <TextSpan>[
|
||||
new DartSyntaxHighlighter(style).format(_exampleCode)
|
||||
DartSyntaxHighlighter(style).format(_exampleCode)
|
||||
]
|
||||
)
|
||||
)
|
||||
@@ -155,9 +155,9 @@ class FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
|
||||
);
|
||||
}
|
||||
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
leading: new IconButton(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(
|
||||
Icons.clear,
|
||||
semanticLabel: 'Close',
|
||||
|
||||
@@ -85,23 +85,23 @@ class GalleryDemo {
|
||||
List<GalleryDemo> _buildGalleryDemos() {
|
||||
final List<GalleryDemo> galleryDemos = <GalleryDemo>[
|
||||
// Demos
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Shrine',
|
||||
subtitle: 'Basic shopping app',
|
||||
icon: GalleryIcons.shrine,
|
||||
category: _kDemos,
|
||||
routeName: ShrineDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new ShrineDemo(),
|
||||
buildRoute: (BuildContext context) => ShrineDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Contact profile',
|
||||
subtitle: 'Address book entry with a flexible appbar',
|
||||
icon: GalleryIcons.account_box,
|
||||
category: _kDemos,
|
||||
routeName: ContactsDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new ContactsDemo(),
|
||||
buildRoute: (BuildContext context) => ContactsDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Animation',
|
||||
subtitle: 'Section organizer',
|
||||
icon: GalleryIcons.animation,
|
||||
@@ -111,138 +111,138 @@ List<GalleryDemo> _buildGalleryDemos() {
|
||||
),
|
||||
|
||||
// Style
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Colors',
|
||||
subtitle: 'All of the predefined colors',
|
||||
icon: GalleryIcons.colors,
|
||||
category: _kStyle,
|
||||
routeName: ColorsDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new ColorsDemo(),
|
||||
buildRoute: (BuildContext context) => ColorsDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Typography',
|
||||
subtitle: 'All of the predefined text styles',
|
||||
icon: GalleryIcons.custom_typography,
|
||||
category: _kStyle,
|
||||
routeName: TypographyDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new TypographyDemo(),
|
||||
buildRoute: (BuildContext context) => TypographyDemo(),
|
||||
),
|
||||
|
||||
// Material Components
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Backdrop',
|
||||
subtitle: 'Select a front layer from back layer',
|
||||
icon: GalleryIcons.backdrop,
|
||||
category: _kMaterialComponents,
|
||||
routeName: BackdropDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new BackdropDemo(),
|
||||
buildRoute: (BuildContext context) => BackdropDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Bottom app bar',
|
||||
subtitle: 'Optional floating action button notch',
|
||||
icon: GalleryIcons.bottom_app_bar,
|
||||
category: _kMaterialComponents,
|
||||
routeName: BottomAppBarDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new BottomAppBarDemo(),
|
||||
buildRoute: (BuildContext context) => BottomAppBarDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Bottom navigation',
|
||||
subtitle: 'Bottom navigation with cross-fading views',
|
||||
icon: GalleryIcons.bottom_navigation,
|
||||
category: _kMaterialComponents,
|
||||
routeName: BottomNavigationDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new BottomNavigationDemo(),
|
||||
buildRoute: (BuildContext context) => BottomNavigationDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Bottom sheet: Modal',
|
||||
subtitle: 'A dismissable bottom sheet',
|
||||
icon: GalleryIcons.bottom_sheets,
|
||||
category: _kMaterialComponents,
|
||||
routeName: ModalBottomSheetDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new ModalBottomSheetDemo(),
|
||||
buildRoute: (BuildContext context) => ModalBottomSheetDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Bottom sheet: Persistent',
|
||||
subtitle: 'A bottom sheet that sticks around',
|
||||
icon: GalleryIcons.bottom_sheet_persistent,
|
||||
category: _kMaterialComponents,
|
||||
routeName: PersistentBottomSheetDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new PersistentBottomSheetDemo(),
|
||||
buildRoute: (BuildContext context) => PersistentBottomSheetDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Buttons',
|
||||
subtitle: 'Flat, raised, dropdown, and more',
|
||||
icon: GalleryIcons.generic_buttons,
|
||||
category: _kMaterialComponents,
|
||||
routeName: ButtonsDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new ButtonsDemo(),
|
||||
buildRoute: (BuildContext context) => ButtonsDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Buttons: Floating Action Button',
|
||||
subtitle: 'FAB with transitions',
|
||||
icon: GalleryIcons.buttons,
|
||||
category: _kMaterialComponents,
|
||||
routeName: TabsFabDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new TabsFabDemo(),
|
||||
buildRoute: (BuildContext context) => TabsFabDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Cards',
|
||||
subtitle: 'Baseline cards with rounded corners',
|
||||
icon: GalleryIcons.cards,
|
||||
category: _kMaterialComponents,
|
||||
routeName: CardsDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new CardsDemo(),
|
||||
buildRoute: (BuildContext context) => CardsDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Chips',
|
||||
subtitle: 'Labeled with delete buttons and avatars',
|
||||
icon: GalleryIcons.chips,
|
||||
category: _kMaterialComponents,
|
||||
routeName: ChipDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new ChipDemo(),
|
||||
buildRoute: (BuildContext context) => ChipDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Data tables',
|
||||
subtitle: 'Rows and columns',
|
||||
icon: GalleryIcons.data_table,
|
||||
category: _kMaterialComponents,
|
||||
routeName: DataTableDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new DataTableDemo(),
|
||||
buildRoute: (BuildContext context) => DataTableDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Dialogs',
|
||||
subtitle: 'Simple, alert, and fullscreen',
|
||||
icon: GalleryIcons.dialogs,
|
||||
category: _kMaterialComponents,
|
||||
routeName: DialogDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new DialogDemo(),
|
||||
buildRoute: (BuildContext context) => DialogDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Elevations',
|
||||
subtitle: 'Shadow values on cards',
|
||||
// TODO(larche): Change to custom icon for elevations when one exists.
|
||||
icon: GalleryIcons.cupertino_progress,
|
||||
category: _kMaterialComponents,
|
||||
routeName: ElevationDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new ElevationDemo(),
|
||||
buildRoute: (BuildContext context) => ElevationDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Expand/collapse list control',
|
||||
subtitle: 'A list with one sub-list level',
|
||||
icon: GalleryIcons.expand_all,
|
||||
category: _kMaterialComponents,
|
||||
routeName: TwoLevelListDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new TwoLevelListDemo(),
|
||||
buildRoute: (BuildContext context) => TwoLevelListDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Expansion panels',
|
||||
subtitle: 'List of expanding panels',
|
||||
icon: GalleryIcons.expand_all,
|
||||
category: _kMaterialComponents,
|
||||
routeName: ExpansionPanelsDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new ExpansionPanelsDemo(),
|
||||
buildRoute: (BuildContext context) => ExpansionPanelsDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Grid',
|
||||
subtitle: 'Row and column layout',
|
||||
icon: GalleryIcons.grid_on,
|
||||
@@ -250,15 +250,15 @@ List<GalleryDemo> _buildGalleryDemos() {
|
||||
routeName: GridListDemo.routeName,
|
||||
buildRoute: (BuildContext context) => const GridListDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Icons',
|
||||
subtitle: 'Enabled and disabled icons with opacity',
|
||||
icon: GalleryIcons.sentiment_very_satisfied,
|
||||
category: _kMaterialComponents,
|
||||
routeName: IconsDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new IconsDemo(),
|
||||
buildRoute: (BuildContext context) => IconsDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Lists',
|
||||
subtitle: 'Scrolling list layouts',
|
||||
icon: GalleryIcons.list_alt,
|
||||
@@ -266,7 +266,7 @@ List<GalleryDemo> _buildGalleryDemos() {
|
||||
routeName: ListDemo.routeName,
|
||||
buildRoute: (BuildContext context) => const ListDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Lists: leave-behind list items',
|
||||
subtitle: 'List items with hidden actions',
|
||||
icon: GalleryIcons.lists_leave_behind,
|
||||
@@ -274,7 +274,7 @@ List<GalleryDemo> _buildGalleryDemos() {
|
||||
routeName: LeaveBehindDemo.routeName,
|
||||
buildRoute: (BuildContext context) => const LeaveBehindDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Lists: reorderable',
|
||||
subtitle: 'Reorderable lists',
|
||||
icon: GalleryIcons.list_alt,
|
||||
@@ -282,7 +282,7 @@ List<GalleryDemo> _buildGalleryDemos() {
|
||||
routeName: ReorderableListDemo.routeName,
|
||||
buildRoute: (BuildContext context) => const ReorderableListDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Menus',
|
||||
subtitle: 'Menu buttons and simple menus',
|
||||
icon: GalleryIcons.more_vert,
|
||||
@@ -290,39 +290,39 @@ List<GalleryDemo> _buildGalleryDemos() {
|
||||
routeName: MenuDemo.routeName,
|
||||
buildRoute: (BuildContext context) => const MenuDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Navigation drawer',
|
||||
subtitle: 'Navigation drawer with standard header',
|
||||
icon: GalleryIcons.menu,
|
||||
category: _kMaterialComponents,
|
||||
routeName: DrawerDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new DrawerDemo(),
|
||||
buildRoute: (BuildContext context) => DrawerDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Pagination',
|
||||
subtitle: 'PageView with indicator',
|
||||
icon: GalleryIcons.page_control,
|
||||
category: _kMaterialComponents,
|
||||
routeName: PageSelectorDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new PageSelectorDemo(),
|
||||
buildRoute: (BuildContext context) => PageSelectorDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Pickers',
|
||||
subtitle: 'Date and time selection widgets',
|
||||
icon: GalleryIcons.event,
|
||||
category: _kMaterialComponents,
|
||||
routeName: DateAndTimePickerDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new DateAndTimePickerDemo(),
|
||||
buildRoute: (BuildContext context) => DateAndTimePickerDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Progress indicators',
|
||||
subtitle: 'Linear, circular, indeterminate',
|
||||
icon: GalleryIcons.progress_activity,
|
||||
category: _kMaterialComponents,
|
||||
routeName: ProgressIndicatorDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new ProgressIndicatorDemo(),
|
||||
buildRoute: (BuildContext context) => ProgressIndicatorDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Pull to refresh',
|
||||
subtitle: 'Refresh indicators',
|
||||
icon: GalleryIcons.refresh,
|
||||
@@ -330,31 +330,31 @@ List<GalleryDemo> _buildGalleryDemos() {
|
||||
routeName: OverscrollDemo.routeName,
|
||||
buildRoute: (BuildContext context) => const OverscrollDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Search',
|
||||
subtitle: 'Expandable search',
|
||||
icon: Icons.search,
|
||||
category: _kMaterialComponents,
|
||||
routeName: SearchDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new SearchDemo(),
|
||||
buildRoute: (BuildContext context) => SearchDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Selection controls',
|
||||
subtitle: 'Checkboxes, radio buttons, and switches',
|
||||
icon: GalleryIcons.check_box,
|
||||
category: _kMaterialComponents,
|
||||
routeName: SelectionControlsDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new SelectionControlsDemo(),
|
||||
buildRoute: (BuildContext context) => SelectionControlsDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Sliders',
|
||||
subtitle: 'Widgets for selecting a value by swiping',
|
||||
icon: GalleryIcons.sliders,
|
||||
category: _kMaterialComponents,
|
||||
routeName: SliderDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new SliderDemo(),
|
||||
buildRoute: (BuildContext context) => SliderDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Snackbar',
|
||||
subtitle: 'Temporary messaging',
|
||||
icon: GalleryIcons.snackbar,
|
||||
@@ -362,23 +362,23 @@ List<GalleryDemo> _buildGalleryDemos() {
|
||||
routeName: SnackBarDemo.routeName,
|
||||
buildRoute: (BuildContext context) => const SnackBarDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Tabs',
|
||||
subtitle: 'Tabs with independently scrollable views',
|
||||
icon: GalleryIcons.tabs,
|
||||
category: _kMaterialComponents,
|
||||
routeName: TabsDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new TabsDemo(),
|
||||
buildRoute: (BuildContext context) => TabsDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Tabs: Scrolling',
|
||||
subtitle: 'Tab bar that scrolls',
|
||||
category: _kMaterialComponents,
|
||||
icon: GalleryIcons.tabs,
|
||||
routeName: ScrollableTabsDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new ScrollableTabsDemo(),
|
||||
buildRoute: (BuildContext context) => ScrollableTabsDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Text fields',
|
||||
subtitle: 'Single line of editable text and numbers',
|
||||
icon: GalleryIcons.text_fields_alt,
|
||||
@@ -386,90 +386,90 @@ List<GalleryDemo> _buildGalleryDemos() {
|
||||
routeName: TextFormFieldDemo.routeName,
|
||||
buildRoute: (BuildContext context) => const TextFormFieldDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Tooltips',
|
||||
subtitle: 'Short message displayed on long-press',
|
||||
icon: GalleryIcons.tooltip,
|
||||
category: _kMaterialComponents,
|
||||
routeName: TooltipDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new TooltipDemo(),
|
||||
buildRoute: (BuildContext context) => TooltipDemo(),
|
||||
),
|
||||
|
||||
// Cupertino Components
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Activity Indicator',
|
||||
icon: GalleryIcons.cupertino_progress,
|
||||
category: _kCupertinoComponents,
|
||||
routeName: CupertinoProgressIndicatorDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new CupertinoProgressIndicatorDemo(),
|
||||
buildRoute: (BuildContext context) => CupertinoProgressIndicatorDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Alerts',
|
||||
icon: GalleryIcons.dialogs,
|
||||
category: _kCupertinoComponents,
|
||||
routeName: CupertinoAlertDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new CupertinoAlertDemo(),
|
||||
buildRoute: (BuildContext context) => CupertinoAlertDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Buttons',
|
||||
icon: GalleryIcons.generic_buttons,
|
||||
category: _kCupertinoComponents,
|
||||
routeName: CupertinoButtonsDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new CupertinoButtonsDemo(),
|
||||
buildRoute: (BuildContext context) => CupertinoButtonsDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Navigation',
|
||||
icon: GalleryIcons.bottom_navigation,
|
||||
category: _kCupertinoComponents,
|
||||
routeName: CupertinoNavigationDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new CupertinoNavigationDemo(),
|
||||
buildRoute: (BuildContext context) => CupertinoNavigationDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Pickers',
|
||||
icon: GalleryIcons.event,
|
||||
category: _kCupertinoComponents,
|
||||
routeName: CupertinoPickerDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new CupertinoPickerDemo(),
|
||||
buildRoute: (BuildContext context) => CupertinoPickerDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Pull to refresh',
|
||||
icon: GalleryIcons.cupertino_pull_to_refresh,
|
||||
category: _kCupertinoComponents,
|
||||
routeName: CupertinoRefreshControlDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new CupertinoRefreshControlDemo(),
|
||||
buildRoute: (BuildContext context) => CupertinoRefreshControlDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Segmented Control',
|
||||
icon: GalleryIcons.tabs,
|
||||
category: _kCupertinoComponents,
|
||||
routeName: CupertinoSegmentedControlDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new CupertinoSegmentedControlDemo(),
|
||||
buildRoute: (BuildContext context) => CupertinoSegmentedControlDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Sliders',
|
||||
icon: GalleryIcons.sliders,
|
||||
category: _kCupertinoComponents,
|
||||
routeName: CupertinoSliderDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new CupertinoSliderDemo(),
|
||||
buildRoute: (BuildContext context) => CupertinoSliderDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Switches',
|
||||
icon: GalleryIcons.cupertino_switch,
|
||||
category: _kCupertinoComponents,
|
||||
routeName: CupertinoSwitchDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new CupertinoSwitchDemo(),
|
||||
buildRoute: (BuildContext context) => CupertinoSwitchDemo(),
|
||||
),
|
||||
|
||||
// Media
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Animated images',
|
||||
subtitle: 'GIF and WebP animations',
|
||||
icon: GalleryIcons.animation,
|
||||
category: _kMedia,
|
||||
routeName: ImagesDemo.routeName,
|
||||
buildRoute: (BuildContext context) => new ImagesDemo(),
|
||||
buildRoute: (BuildContext context) => ImagesDemo(),
|
||||
),
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Video',
|
||||
subtitle: 'Video playback',
|
||||
icon: GalleryIcons.drive_video,
|
||||
@@ -483,7 +483,7 @@ List<GalleryDemo> _buildGalleryDemos() {
|
||||
// in (release builds) the performance tests.
|
||||
assert(() {
|
||||
galleryDemos.insert(0,
|
||||
new GalleryDemo(
|
||||
GalleryDemo(
|
||||
title: 'Pesto',
|
||||
subtitle: 'Simple recipe browser',
|
||||
icon: Icons.adjust,
|
||||
@@ -504,7 +504,7 @@ final Set<GalleryDemoCategory> kAllGalleryDemoCategories =
|
||||
kAllGalleryDemos.map<GalleryDemoCategory>((GalleryDemo demo) => demo.category).toSet();
|
||||
|
||||
final Map<GalleryDemoCategory, List<GalleryDemo>> kGalleryCategoryToDemos =
|
||||
new Map<GalleryDemoCategory, List<GalleryDemo>>.fromIterable(
|
||||
Map<GalleryDemoCategory, List<GalleryDemo>>.fromIterable(
|
||||
kAllGalleryDemoCategories,
|
||||
value: (dynamic category) {
|
||||
return kAllGalleryDemos.where((GalleryDemo demo) => demo.category == category).toList();
|
||||
|
||||
@@ -15,7 +15,7 @@ class ButtonsDemo {
|
||||
|
||||
// START buttons_raised
|
||||
// Create a raised button.
|
||||
new RaisedButton(
|
||||
RaisedButton(
|
||||
child: const Text('BUTTON TITLE'),
|
||||
onPressed: () {
|
||||
// Perform some action
|
||||
@@ -32,7 +32,7 @@ const RaisedButton(
|
||||
|
||||
// Create a button with an icon and a
|
||||
// title.
|
||||
new RaisedButton.icon(
|
||||
RaisedButton.icon(
|
||||
icon: const Icon(Icons.add, size: 18.0),
|
||||
label: const Text('BUTTON TITLE'),
|
||||
onPressed: () {
|
||||
@@ -43,7 +43,7 @@ new RaisedButton.icon(
|
||||
|
||||
// START buttons_outline
|
||||
// Create an outline button.
|
||||
new OutlineButton(
|
||||
OutlineButton(
|
||||
child: const Text('BUTTON TITLE'),
|
||||
onPressed: () {
|
||||
// Perform some action
|
||||
@@ -60,7 +60,7 @@ const OutlineButton(
|
||||
|
||||
// Create a button with an icon and a
|
||||
// title.
|
||||
new OutlineButton.icon(
|
||||
OutlineButton.icon(
|
||||
icon: const Icon(Icons.add, size: 18.0),
|
||||
label: const Text('BUTTON TITLE'),
|
||||
onPressed: () {
|
||||
@@ -71,7 +71,7 @@ new OutlineButton.icon(
|
||||
|
||||
// START buttons_flat
|
||||
// Create a flat button.
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('BUTTON TITLE'),
|
||||
onPressed: () {
|
||||
// Perform some action
|
||||
@@ -93,7 +93,7 @@ const FlatButton(
|
||||
String dropdownValue;
|
||||
|
||||
// Dropdown button with string values.
|
||||
new DropdownButton<String>(
|
||||
DropdownButton<String>(
|
||||
value: dropdownValue,
|
||||
onChanged: (String newValue) {
|
||||
// null indicates the user didn't select a
|
||||
@@ -105,9 +105,9 @@ new DropdownButton<String>(
|
||||
},
|
||||
items: <String>['One', 'Two', 'Free', 'Four']
|
||||
.map((String value) {
|
||||
return new DropdownMenuItem<String>(
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: new Text(value));
|
||||
child: Text(value));
|
||||
})
|
||||
.toList()
|
||||
);
|
||||
@@ -119,7 +119,7 @@ new DropdownButton<String>(
|
||||
bool value;
|
||||
|
||||
// Toggleable icon button.
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.thumb_up),
|
||||
onPressed: () {
|
||||
setState(() => value = !value);
|
||||
@@ -131,8 +131,8 @@ new IconButton(
|
||||
|
||||
// START buttons_action
|
||||
// Floating action button in Scaffold.
|
||||
new Scaffold(
|
||||
appBar: new AppBar(
|
||||
Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Demo')
|
||||
),
|
||||
floatingActionButton: const FloatingActionButton(
|
||||
@@ -155,7 +155,7 @@ class SelectionControls {
|
||||
bool checkboxValue = false;
|
||||
|
||||
// Create a checkbox.
|
||||
new Checkbox(
|
||||
Checkbox(
|
||||
value: checkboxValue,
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
@@ -165,7 +165,7 @@ new Checkbox(
|
||||
);
|
||||
|
||||
// Create a tristate checkbox.
|
||||
new Checkbox(
|
||||
Checkbox(
|
||||
tristate: true,
|
||||
value: checkboxValue,
|
||||
onChanged: (bool value) {
|
||||
@@ -194,19 +194,19 @@ void handleRadioValueChanged(int value) {
|
||||
}
|
||||
|
||||
// Creates a set of radio buttons.
|
||||
new Row(
|
||||
Row(
|
||||
children: <Widget>[
|
||||
new Radio<int>(
|
||||
Radio<int>(
|
||||
value: 0,
|
||||
groupValue: radioValue,
|
||||
onChanged: handleRadioValueChanged
|
||||
),
|
||||
new Radio<int>(
|
||||
Radio<int>(
|
||||
value: 1,
|
||||
groupValue: radioValue,
|
||||
onChanged: handleRadioValueChanged
|
||||
),
|
||||
new Radio<int>(
|
||||
Radio<int>(
|
||||
value: 2,
|
||||
groupValue: radioValue,
|
||||
onChanged: handleRadioValueChanged
|
||||
@@ -228,7 +228,7 @@ const Radio<int>(
|
||||
bool switchValue = false;
|
||||
|
||||
// Create a switch.
|
||||
new Switch(
|
||||
Switch(
|
||||
value: switchValue,
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
@@ -251,7 +251,7 @@ class GridLists {
|
||||
// START gridlists
|
||||
// Creates a scrollable grid list with images
|
||||
// loaded from the web.
|
||||
new GridView.count(
|
||||
GridView.count(
|
||||
crossAxisCount: 3,
|
||||
childAspectRatio: 1.0,
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
@@ -264,11 +264,11 @@ new GridView.count(
|
||||
'...',
|
||||
'https://example.com/image-n.jpg'
|
||||
].map((String url) {
|
||||
return new GridTile(
|
||||
footer: new GridTileBar(
|
||||
title: new Text(url)
|
||||
return GridTile(
|
||||
footer: GridTileBar(
|
||||
title: Text(url)
|
||||
),
|
||||
child: new Image.network(url, fit: BoxFit.cover)
|
||||
child: Image.network(url, fit: BoxFit.cover)
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
@@ -280,7 +280,7 @@ new GridView.count(
|
||||
class AnimatedImage {
|
||||
void animatedImage() {
|
||||
// START animated_image
|
||||
new Image.network('https://example.com/animated-image.gif');
|
||||
Image.network('https://example.com/animated-image.gif');
|
||||
// END
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ class _FlutterLogo extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Center(
|
||||
child: new Container(
|
||||
return Center(
|
||||
child: Container(
|
||||
width: 34.0,
|
||||
height: 34.0,
|
||||
decoration: const BoxDecoration(
|
||||
@@ -56,29 +56,29 @@ class _CategoryItem extends StatelessWidget {
|
||||
|
||||
// This repaint boundary prevents the entire _CategoriesPage from being
|
||||
// repainted when the button's ink splash animates.
|
||||
return new RepaintBoundary(
|
||||
child: new RawMaterialButton(
|
||||
return RepaintBoundary(
|
||||
child: RawMaterialButton(
|
||||
padding: EdgeInsets.zero,
|
||||
splashColor: theme.primaryColor.withOpacity(0.12),
|
||||
highlightColor: Colors.transparent,
|
||||
onPressed: onTap,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(6.0),
|
||||
child: new Icon(
|
||||
child: Icon(
|
||||
category.icon,
|
||||
size: 60.0,
|
||||
color: isDark ? Colors.white : _kFlutterBlue,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
new Container(
|
||||
Container(
|
||||
height: 48.0,
|
||||
alignment: Alignment.center,
|
||||
child: new Text(
|
||||
child: Text(
|
||||
category.name,
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.subhead.copyWith(
|
||||
@@ -110,14 +110,14 @@ class _CategoriesPage extends StatelessWidget {
|
||||
final List<GalleryDemoCategory> categoriesList = categories.toList();
|
||||
final int columnCount = (MediaQuery.of(context).orientation == Orientation.portrait) ? 2 : 3;
|
||||
|
||||
return new Semantics(
|
||||
return Semantics(
|
||||
scopesRoute: true,
|
||||
namesRoute: true,
|
||||
label: 'categories',
|
||||
explicitChildNodes: true,
|
||||
child: new SingleChildScrollView(
|
||||
child: SingleChildScrollView(
|
||||
key: const PageStorageKey<String>('categories'),
|
||||
child: new LayoutBuilder(
|
||||
child: LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) {
|
||||
final double columnWidth = constraints.biggest.width / columnCount.toDouble();
|
||||
final double rowHeight = math.min(225.0, columnWidth * aspectRatio);
|
||||
@@ -126,24 +126,24 @@ class _CategoriesPage extends StatelessWidget {
|
||||
// This repaint boundary prevents the inner contents of the front layer
|
||||
// from repainting when the backdrop toggle triggers a repaint on the
|
||||
// LayoutBuilder.
|
||||
return new RepaintBoundary(
|
||||
child: new Column(
|
||||
return RepaintBoundary(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: new List<Widget>.generate(rowCount, (int rowIndex) {
|
||||
children: List<Widget>.generate(rowCount, (int rowIndex) {
|
||||
final int columnCountForRow = rowIndex == rowCount - 1
|
||||
? categories.length - columnCount * math.max(0, rowCount - 1)
|
||||
: columnCount;
|
||||
|
||||
return new Row(
|
||||
children: new List<Widget>.generate(columnCountForRow, (int columnIndex) {
|
||||
return Row(
|
||||
children: List<Widget>.generate(columnCountForRow, (int columnIndex) {
|
||||
final int index = rowIndex * columnCount + columnIndex;
|
||||
final GalleryDemoCategory category = categoriesList[index];
|
||||
|
||||
return new SizedBox(
|
||||
return SizedBox(
|
||||
width: columnWidth,
|
||||
height: rowHeight,
|
||||
child: new _CategoryItem(
|
||||
child: _CategoryItem(
|
||||
category: category,
|
||||
onTap: () {
|
||||
onCategoryTap(category);
|
||||
@@ -184,7 +184,7 @@ class _DemoItem extends StatelessWidget {
|
||||
final double textScaleFactor = MediaQuery.textScaleFactorOf(context);
|
||||
|
||||
final List<Widget> titleChildren = <Widget>[
|
||||
new Text(
|
||||
Text(
|
||||
demo.title,
|
||||
style: theme.textTheme.subhead.copyWith(
|
||||
color: isDark ? Colors.white : const Color(0xFF202124),
|
||||
@@ -193,7 +193,7 @@ class _DemoItem extends StatelessWidget {
|
||||
];
|
||||
if (demo.subtitle != null) {
|
||||
titleChildren.add(
|
||||
new Text(
|
||||
Text(
|
||||
demo.subtitle,
|
||||
style: theme.textTheme.body1.copyWith(
|
||||
color: isDark ? Colors.white : const Color(0xFF60646B)
|
||||
@@ -202,29 +202,29 @@ class _DemoItem extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
return new RawMaterialButton(
|
||||
return RawMaterialButton(
|
||||
padding: EdgeInsets.zero,
|
||||
splashColor: theme.primaryColor.withOpacity(0.12),
|
||||
highlightColor: Colors.transparent,
|
||||
onPressed: () {
|
||||
_launchDemo(context);
|
||||
},
|
||||
child: new Container(
|
||||
constraints: new BoxConstraints(minHeight: _kDemoItemHeight * textScaleFactor),
|
||||
child: new Row(
|
||||
child: Container(
|
||||
constraints: BoxConstraints(minHeight: _kDemoItemHeight * textScaleFactor),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
Container(
|
||||
width: 56.0,
|
||||
height: 56.0,
|
||||
alignment: Alignment.center,
|
||||
child: new Icon(
|
||||
child: Icon(
|
||||
demo.icon,
|
||||
size: 24.0,
|
||||
color: isDark ? Colors.white : _kFlutterBlue,
|
||||
),
|
||||
),
|
||||
new Expanded(
|
||||
child: new Column(
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: titleChildren,
|
||||
@@ -248,18 +248,18 @@ class _DemosPage extends StatelessWidget {
|
||||
// When overriding ListView.padding, it is necessary to manually handle
|
||||
// safe areas.
|
||||
final double windowBottomPadding = MediaQuery.of(context).padding.bottom;
|
||||
return new KeyedSubtree(
|
||||
return KeyedSubtree(
|
||||
key: const ValueKey<String>('GalleryDemoList'), // So the tests can find this ListView
|
||||
child: new Semantics(
|
||||
child: Semantics(
|
||||
scopesRoute: true,
|
||||
namesRoute: true,
|
||||
label: category.name,
|
||||
explicitChildNodes: true,
|
||||
child: new ListView(
|
||||
key: new PageStorageKey<String>(category.name),
|
||||
padding: new EdgeInsets.only(top: 8.0, bottom: windowBottomPadding),
|
||||
child: ListView(
|
||||
key: PageStorageKey<String>(category.name),
|
||||
padding: EdgeInsets.only(top: 8.0, bottom: windowBottomPadding),
|
||||
children: kGalleryCategoryToDemos[category].map<Widget>((GalleryDemo demo) {
|
||||
return new _DemoItem(demo: demo);
|
||||
return _DemoItem(demo: demo);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
@@ -282,11 +282,11 @@ class GalleryHome extends StatefulWidget {
|
||||
final bool testMode;
|
||||
|
||||
@override
|
||||
_GalleryHomeState createState() => new _GalleryHomeState();
|
||||
_GalleryHomeState createState() => _GalleryHomeState();
|
||||
}
|
||||
|
||||
class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStateMixin {
|
||||
static final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
static final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
AnimationController _controller;
|
||||
GalleryDemoCategory _category;
|
||||
|
||||
@@ -294,7 +294,7 @@ class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStat
|
||||
List<Widget> children = previousChildren;
|
||||
if (currentChild != null)
|
||||
children = children.toList()..add(currentChild);
|
||||
return new Stack(
|
||||
return Stack(
|
||||
children: children,
|
||||
alignment: Alignment.topCenter,
|
||||
);
|
||||
@@ -305,7 +305,7 @@ class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStat
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = new AnimationController(
|
||||
_controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 600),
|
||||
debugLabel: 'preview banner',
|
||||
vsync: this,
|
||||
@@ -328,50 +328,50 @@ class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStat
|
||||
const Curve switchOutCurve = Interval(0.4, 1.0, curve: Curves.fastOutSlowIn);
|
||||
const Curve switchInCurve = Interval(0.4, 1.0, curve: Curves.fastOutSlowIn);
|
||||
|
||||
Widget home = new Scaffold(
|
||||
Widget home = Scaffold(
|
||||
key: _scaffoldKey,
|
||||
backgroundColor: isDark ? _kFlutterBlue : theme.primaryColor,
|
||||
body: new SafeArea(
|
||||
body: SafeArea(
|
||||
bottom: false,
|
||||
child: new WillPopScope(
|
||||
child: WillPopScope(
|
||||
onWillPop: () {
|
||||
// Pop the category page if Android back button is pressed.
|
||||
if (_category != null) {
|
||||
setState(() => _category = null);
|
||||
return new Future<bool>.value(false);
|
||||
return Future<bool>.value(false);
|
||||
}
|
||||
return new Future<bool>.value(true);
|
||||
return Future<bool>.value(true);
|
||||
},
|
||||
child: new Backdrop(
|
||||
child: Backdrop(
|
||||
backTitle: const Text('Options'),
|
||||
backLayer: widget.optionsPage,
|
||||
frontAction: new AnimatedSwitcher(
|
||||
frontAction: AnimatedSwitcher(
|
||||
duration: _kFrontLayerSwitchDuration,
|
||||
switchOutCurve: switchOutCurve,
|
||||
switchInCurve: switchInCurve,
|
||||
child: _category == null
|
||||
? const _FlutterLogo()
|
||||
: new IconButton(
|
||||
: IconButton(
|
||||
icon: const BackButtonIcon(),
|
||||
tooltip: 'Back',
|
||||
onPressed: () => setState(() => _category = null),
|
||||
),
|
||||
),
|
||||
frontTitle: new AnimatedSwitcher(
|
||||
frontTitle: AnimatedSwitcher(
|
||||
duration: _kFrontLayerSwitchDuration,
|
||||
child: _category == null
|
||||
? const Text('Flutter gallery')
|
||||
: new Text(_category.name),
|
||||
: Text(_category.name),
|
||||
),
|
||||
frontHeading: widget.testMode ? null : new Container(height: 24.0),
|
||||
frontLayer: new AnimatedSwitcher(
|
||||
frontHeading: widget.testMode ? null : Container(height: 24.0),
|
||||
frontLayer: AnimatedSwitcher(
|
||||
duration: _kFrontLayerSwitchDuration,
|
||||
switchOutCurve: switchOutCurve,
|
||||
switchInCurve: switchInCurve,
|
||||
layoutBuilder: centerHome ? _centerHomeLayout : _topHomeLayout,
|
||||
child: _category != null
|
||||
? new _DemosPage(_category)
|
||||
: new _CategoriesPage(
|
||||
? _DemosPage(_category)
|
||||
: _CategoriesPage(
|
||||
categories: kAllGalleryDemoCategories,
|
||||
onCategoryTap: (GalleryDemoCategory category) {
|
||||
setState(() => _category = category);
|
||||
@@ -389,12 +389,12 @@ class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStat
|
||||
}());
|
||||
|
||||
if (GalleryHome.showPreviewBanner) {
|
||||
home = new Stack(
|
||||
home = Stack(
|
||||
fit: StackFit.expand,
|
||||
children: <Widget>[
|
||||
home,
|
||||
new FadeTransition(
|
||||
opacity: new CurvedAnimation(parent: _controller, curve: Curves.easeInOut),
|
||||
FadeTransition(
|
||||
opacity: CurvedAnimation(parent: _controller, curve: Curves.easeInOut),
|
||||
child: const Banner(
|
||||
message: 'PREVIEW',
|
||||
location: BannerLocation.topEnd,
|
||||
@@ -403,7 +403,7 @@ class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStat
|
||||
]
|
||||
);
|
||||
}
|
||||
home = new AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
home = AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
child: home,
|
||||
value: SystemUiOverlayStyle.light
|
||||
);
|
||||
|
||||
@@ -39,7 +39,7 @@ class GalleryOptions {
|
||||
bool showRasterCacheImagesCheckerboard,
|
||||
bool showOffscreenLayersCheckerboard,
|
||||
}) {
|
||||
return new GalleryOptions(
|
||||
return GalleryOptions(
|
||||
theme: theme ?? this.theme,
|
||||
textScaleFactor: textScaleFactor ?? this.textScaleFactor,
|
||||
textDirection: textDirection ?? this.textDirection,
|
||||
@@ -95,16 +95,16 @@ class _OptionsItem extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final double textScaleFactor = MediaQuery.textScaleFactorOf(context);
|
||||
|
||||
return new MergeSemantics(
|
||||
child: new Container(
|
||||
constraints: new BoxConstraints(minHeight: _kItemHeight * textScaleFactor),
|
||||
return MergeSemantics(
|
||||
child: Container(
|
||||
constraints: BoxConstraints(minHeight: _kItemHeight * textScaleFactor),
|
||||
padding: _kItemPadding,
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: new DefaultTextStyle(
|
||||
child: DefaultTextStyle(
|
||||
style: DefaultTextStyle.of(context).style,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.fade,
|
||||
child: new IconTheme(
|
||||
child: IconTheme(
|
||||
data: Theme.of(context).primaryIconTheme,
|
||||
child: child,
|
||||
),
|
||||
@@ -126,11 +126,11 @@ class _BooleanItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bool isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
return new _OptionsItem(
|
||||
child: new Row(
|
||||
return _OptionsItem(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Expanded(child: new Text(title)),
|
||||
new Switch(
|
||||
Expanded(child: Text(title)),
|
||||
Switch(
|
||||
key: switchKey,
|
||||
value: value,
|
||||
onChanged: onChanged,
|
||||
@@ -151,10 +151,10 @@ class _ActionItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new _OptionsItem(
|
||||
child: new _FlatButton(
|
||||
return _OptionsItem(
|
||||
child: _FlatButton(
|
||||
onPressed: onTap,
|
||||
child: new Text(text),
|
||||
child: Text(text),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -168,10 +168,10 @@ class _FlatButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new FlatButton(
|
||||
return FlatButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: new DefaultTextStyle(
|
||||
child: DefaultTextStyle(
|
||||
style: Theme.of(context).primaryTextTheme.subhead,
|
||||
child: child,
|
||||
),
|
||||
@@ -187,14 +187,14 @@ class _Heading extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return new _OptionsItem(
|
||||
child: new DefaultTextStyle(
|
||||
return _OptionsItem(
|
||||
child: DefaultTextStyle(
|
||||
style: theme.textTheme.body1.copyWith(
|
||||
fontFamily: 'GoogleSans',
|
||||
color: theme.accentColor,
|
||||
),
|
||||
child: new Semantics(
|
||||
child: new Text(text),
|
||||
child: Semantics(
|
||||
child: Text(text),
|
||||
header: true,
|
||||
),
|
||||
),
|
||||
@@ -210,7 +210,7 @@ class _ThemeItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new _BooleanItem(
|
||||
return _BooleanItem(
|
||||
'Dark Theme',
|
||||
options.theme == kDarkGalleryTheme,
|
||||
(bool value) {
|
||||
@@ -233,29 +233,29 @@ class _TextScaleFactorItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new _OptionsItem(
|
||||
child: new Row(
|
||||
return _OptionsItem(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
child: new Column(
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
const Text('Text size'),
|
||||
new Text(
|
||||
Text(
|
||||
'${options.textScaleFactor.label}',
|
||||
style: Theme.of(context).primaryTextTheme.body1,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
new PopupMenuButton<GalleryTextScaleValue>(
|
||||
PopupMenuButton<GalleryTextScaleValue>(
|
||||
padding: const EdgeInsetsDirectional.only(end: 16.0),
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
itemBuilder: (BuildContext context) {
|
||||
return kAllGalleryTextScaleValues.map((GalleryTextScaleValue scaleValue) {
|
||||
return new PopupMenuItem<GalleryTextScaleValue>(
|
||||
return PopupMenuItem<GalleryTextScaleValue>(
|
||||
value: scaleValue,
|
||||
child: new Text(scaleValue.label),
|
||||
child: Text(scaleValue.label),
|
||||
);
|
||||
}).toList();
|
||||
},
|
||||
@@ -279,7 +279,7 @@ class _TextDirectionItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new _BooleanItem(
|
||||
return _BooleanItem(
|
||||
'Force RTL',
|
||||
options.textDirection == TextDirection.rtl,
|
||||
(bool value) {
|
||||
@@ -302,7 +302,7 @@ class _TimeDilationItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new _BooleanItem(
|
||||
return _BooleanItem(
|
||||
'Slow motion',
|
||||
options.timeDilation != 1.0,
|
||||
(bool value) {
|
||||
@@ -338,29 +338,29 @@ class _PlatformItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new _OptionsItem(
|
||||
child: new Row(
|
||||
return _OptionsItem(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
child: new Column(
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
const Text('Platform mechanics'),
|
||||
new Text(
|
||||
Text(
|
||||
'${_platformLabel(options.platform)}',
|
||||
style: Theme.of(context).primaryTextTheme.body1,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
new PopupMenuButton<TargetPlatform>(
|
||||
PopupMenuButton<TargetPlatform>(
|
||||
padding: const EdgeInsetsDirectional.only(end: 16.0),
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
itemBuilder: (BuildContext context) {
|
||||
return TargetPlatform.values.map((TargetPlatform platform) {
|
||||
return new PopupMenuItem<TargetPlatform>(
|
||||
return PopupMenuItem<TargetPlatform>(
|
||||
value: platform,
|
||||
child: new Text(_platformLabel(platform)),
|
||||
child: Text(_platformLabel(platform)),
|
||||
);
|
||||
}).toList();
|
||||
},
|
||||
@@ -403,7 +403,7 @@ class GalleryOptionsPage extends StatelessWidget {
|
||||
|
||||
if (options.showOffscreenLayersCheckerboard != null) {
|
||||
items.add(
|
||||
new _BooleanItem(
|
||||
_BooleanItem(
|
||||
'Highlight offscreen layers',
|
||||
options.showOffscreenLayersCheckerboard,
|
||||
(bool value) {
|
||||
@@ -414,7 +414,7 @@ class GalleryOptionsPage extends StatelessWidget {
|
||||
}
|
||||
if (options.showRasterCacheImagesCheckerboard != null) {
|
||||
items.add(
|
||||
new _BooleanItem(
|
||||
_BooleanItem(
|
||||
'Highlight raster cache images',
|
||||
options.showRasterCacheImagesCheckerboard,
|
||||
(bool value) {
|
||||
@@ -425,7 +425,7 @@ class GalleryOptionsPage extends StatelessWidget {
|
||||
}
|
||||
if (options.showPerformanceOverlay != null) {
|
||||
items.add(
|
||||
new _BooleanItem(
|
||||
_BooleanItem(
|
||||
'Show performance overlay',
|
||||
options.showPerformanceOverlay,
|
||||
(bool value) {
|
||||
@@ -442,29 +442,29 @@ class GalleryOptionsPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
|
||||
return new DefaultTextStyle(
|
||||
return DefaultTextStyle(
|
||||
style: theme.primaryTextTheme.subhead,
|
||||
child: new ListView(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.only(bottom: 124.0),
|
||||
children: <Widget>[
|
||||
const _Heading('Display'),
|
||||
new _ThemeItem(options, onOptionsChanged),
|
||||
new _TextScaleFactorItem(options, onOptionsChanged),
|
||||
new _TextDirectionItem(options, onOptionsChanged),
|
||||
new _TimeDilationItem(options, onOptionsChanged),
|
||||
_ThemeItem(options, onOptionsChanged),
|
||||
_TextScaleFactorItem(options, onOptionsChanged),
|
||||
_TextDirectionItem(options, onOptionsChanged),
|
||||
_TimeDilationItem(options, onOptionsChanged),
|
||||
const Divider(),
|
||||
const _Heading('Platform mechanics'),
|
||||
new _PlatformItem(options, onOptionsChanged),
|
||||
_PlatformItem(options, onOptionsChanged),
|
||||
]..addAll(
|
||||
_enabledDiagnosticItems(),
|
||||
)..addAll(
|
||||
<Widget>[
|
||||
const Divider(),
|
||||
const _Heading('Flutter gallery'),
|
||||
new _ActionItem('About Flutter Gallery', () {
|
||||
_ActionItem('About Flutter Gallery', () {
|
||||
showGalleryAboutDialog(context);
|
||||
}),
|
||||
new _ActionItem('Send feedback', onSendFeedback),
|
||||
_ActionItem('Send feedback', onSendFeedback),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -18,7 +18,7 @@ class SyntaxHighlighterStyle {
|
||||
});
|
||||
|
||||
static SyntaxHighlighterStyle lightThemeStyle() {
|
||||
return new SyntaxHighlighterStyle(
|
||||
return SyntaxHighlighterStyle(
|
||||
baseStyle: const TextStyle(color: Color(0xFF000000)),
|
||||
numberStyle: const TextStyle(color: Color(0xFF1565C0)),
|
||||
commentStyle: const TextStyle(color: Color(0xFF9E9E9E)),
|
||||
@@ -31,7 +31,7 @@ class SyntaxHighlighterStyle {
|
||||
}
|
||||
|
||||
static SyntaxHighlighterStyle darkThemeStyle() {
|
||||
return new SyntaxHighlighterStyle(
|
||||
return SyntaxHighlighterStyle(
|
||||
baseStyle: const TextStyle(color: Color(0xFFFFFFFF)),
|
||||
numberStyle: const TextStyle(color: Color(0xFF1565C0)),
|
||||
commentStyle: const TextStyle(color: Color(0xFF9E9E9E)),
|
||||
@@ -87,7 +87,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
@override
|
||||
TextSpan format(String src) {
|
||||
_src = src;
|
||||
_scanner = new StringScanner(_src);
|
||||
_scanner = StringScanner(_src);
|
||||
|
||||
if (_generateSpans()) {
|
||||
// Successfully parsed the code
|
||||
@@ -96,20 +96,20 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
|
||||
for (_HighlightSpan span in _spans) {
|
||||
if (currentPosition != span.start)
|
||||
formattedText.add(new TextSpan(text: _src.substring(currentPosition, span.start)));
|
||||
formattedText.add(TextSpan(text: _src.substring(currentPosition, span.start)));
|
||||
|
||||
formattedText.add(new TextSpan(style: span.textStyle(_style), text: span.textForSpan(_src)));
|
||||
formattedText.add(TextSpan(style: span.textStyle(_style), text: span.textForSpan(_src)));
|
||||
|
||||
currentPosition = span.end;
|
||||
}
|
||||
|
||||
if (currentPosition != _src.length)
|
||||
formattedText.add(new TextSpan(text: _src.substring(currentPosition, _src.length)));
|
||||
formattedText.add(TextSpan(text: _src.substring(currentPosition, _src.length)));
|
||||
|
||||
return new TextSpan(style: _style.baseStyle, children: formattedText);
|
||||
return TextSpan(style: _style.baseStyle, children: formattedText);
|
||||
} else {
|
||||
// Parsing failed, return with only basic formatting
|
||||
return new TextSpan(style: _style.baseStyle, text: src);
|
||||
return TextSpan(style: _style.baseStyle, text: src);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,11 +118,11 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
|
||||
while (!_scanner.isDone) {
|
||||
// Skip White space
|
||||
_scanner.scan(new RegExp(r'\s+'));
|
||||
_scanner.scan(RegExp(r'\s+'));
|
||||
|
||||
// Block comments
|
||||
if (_scanner.scan(new RegExp(r'/\*(.|\n)*\*/'))) {
|
||||
_spans.add(new _HighlightSpan(
|
||||
if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.comment,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
@@ -136,14 +136,14 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
|
||||
bool eof = false;
|
||||
int endComment;
|
||||
if (_scanner.scan(new RegExp(r'.*\n'))) {
|
||||
if (_scanner.scan(RegExp(r'.*\n'))) {
|
||||
endComment = _scanner.lastMatch.end - 1;
|
||||
} else {
|
||||
eof = true;
|
||||
endComment = _src.length;
|
||||
}
|
||||
|
||||
_spans.add(new _HighlightSpan(
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.comment,
|
||||
startComment,
|
||||
endComment
|
||||
@@ -156,8 +156,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
}
|
||||
|
||||
// Raw r"String"
|
||||
if (_scanner.scan(new RegExp(r'r".*"'))) {
|
||||
_spans.add(new _HighlightSpan(
|
||||
if (_scanner.scan(RegExp(r'r".*"'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
@@ -166,8 +166,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
}
|
||||
|
||||
// Raw r'String'
|
||||
if (_scanner.scan(new RegExp(r"r'.*'"))) {
|
||||
_spans.add(new _HighlightSpan(
|
||||
if (_scanner.scan(RegExp(r"r'.*'"))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
@@ -176,8 +176,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
}
|
||||
|
||||
// Multiline """String"""
|
||||
if (_scanner.scan(new RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) {
|
||||
_spans.add(new _HighlightSpan(
|
||||
if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
@@ -186,8 +186,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
}
|
||||
|
||||
// Multiline '''String'''
|
||||
if (_scanner.scan(new RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) {
|
||||
_spans.add(new _HighlightSpan(
|
||||
if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
@@ -196,8 +196,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
}
|
||||
|
||||
// "String"
|
||||
if (_scanner.scan(new RegExp(r'"(?:[^"\\]|\\.)*"'))) {
|
||||
_spans.add(new _HighlightSpan(
|
||||
if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
@@ -206,8 +206,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
}
|
||||
|
||||
// 'String'
|
||||
if (_scanner.scan(new RegExp(r"'(?:[^'\\]|\\.)*'"))) {
|
||||
_spans.add(new _HighlightSpan(
|
||||
if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
@@ -216,8 +216,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
}
|
||||
|
||||
// Double
|
||||
if (_scanner.scan(new RegExp(r'\d+\.\d+'))) {
|
||||
_spans.add(new _HighlightSpan(
|
||||
if (_scanner.scan(RegExp(r'\d+\.\d+'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.number,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
@@ -226,8 +226,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
}
|
||||
|
||||
// Integer
|
||||
if (_scanner.scan(new RegExp(r'\d+'))) {
|
||||
_spans.add(new _HighlightSpan(
|
||||
if (_scanner.scan(RegExp(r'\d+'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.number,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end)
|
||||
@@ -236,8 +236,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
}
|
||||
|
||||
// Punctuation
|
||||
if (_scanner.scan(new RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) {
|
||||
_spans.add(new _HighlightSpan(
|
||||
if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.punctuation,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
@@ -246,8 +246,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
}
|
||||
|
||||
// Meta data
|
||||
if (_scanner.scan(new RegExp(r'@\w+'))) {
|
||||
_spans.add(new _HighlightSpan(
|
||||
if (_scanner.scan(RegExp(r'@\w+'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.keyword,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
@@ -256,7 +256,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
}
|
||||
|
||||
// Words
|
||||
if (_scanner.scan(new RegExp(r'\w+'))) {
|
||||
if (_scanner.scan(RegExp(r'\w+'))) {
|
||||
_HighlightType type;
|
||||
|
||||
String word = _scanner.lastMatch[0];
|
||||
@@ -273,7 +273,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
type = _HighlightType.constant;
|
||||
|
||||
if (type != null) {
|
||||
_spans.add(new _HighlightSpan(
|
||||
_spans.add(_HighlightSpan(
|
||||
type,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
@@ -296,7 +296,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
void _simplify() {
|
||||
for (int i = _spans.length - 2; i >= 0; i -= 1) {
|
||||
if (_spans[i].type == _spans[i + 1].type && _spans[i].end == _spans[i + 1].start) {
|
||||
_spans[i] = new _HighlightSpan(
|
||||
_spans[i] = _HighlightSpan(
|
||||
_spans[i].type,
|
||||
_spans[i].start,
|
||||
_spans[i + 1].end
|
||||
|
||||
@@ -11,8 +11,8 @@ class GalleryTheme {
|
||||
final ThemeData data;
|
||||
}
|
||||
|
||||
final GalleryTheme kDarkGalleryTheme = new GalleryTheme._('Dark', _buildDarkTheme());
|
||||
final GalleryTheme kLightGalleryTheme = new GalleryTheme._('Light', _buildLightTheme());
|
||||
final GalleryTheme kDarkGalleryTheme = GalleryTheme._('Dark', _buildDarkTheme());
|
||||
final GalleryTheme kLightGalleryTheme = GalleryTheme._('Light', _buildLightTheme());
|
||||
|
||||
TextTheme _buildTextTheme(TextTheme base) {
|
||||
return base.copyWith(
|
||||
@@ -24,7 +24,7 @@ TextTheme _buildTextTheme(TextTheme base) {
|
||||
|
||||
ThemeData _buildDarkTheme() {
|
||||
const Color primaryColor = Color(0xFF0175c2);
|
||||
final ThemeData base = new ThemeData.dark();
|
||||
final ThemeData base = ThemeData.dark();
|
||||
return base.copyWith(
|
||||
primaryColor: primaryColor,
|
||||
buttonColor: primaryColor,
|
||||
@@ -45,7 +45,7 @@ ThemeData _buildDarkTheme() {
|
||||
|
||||
ThemeData _buildLightTheme() {
|
||||
const Color primaryColor = Color(0xFF0175c2);
|
||||
final ThemeData base = new ThemeData.light();
|
||||
final ThemeData base = ThemeData.light();
|
||||
return base.copyWith(
|
||||
primaryColor: primaryColor,
|
||||
buttonColor: primaryColor,
|
||||
|
||||
@@ -19,7 +19,7 @@ class Updater extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
State createState() => new UpdaterState();
|
||||
State createState() => UpdaterState();
|
||||
}
|
||||
|
||||
class UpdaterState extends State<Updater> {
|
||||
@@ -33,10 +33,10 @@ class UpdaterState extends State<Updater> {
|
||||
Future<void> _checkForUpdates() async {
|
||||
// Only prompt once a day
|
||||
if (_lastUpdateCheck != null &&
|
||||
new DateTime.now().difference(_lastUpdateCheck) < const Duration(days: 1)) {
|
||||
DateTime.now().difference(_lastUpdateCheck) < const Duration(days: 1)) {
|
||||
return null; // We already checked for updates recently
|
||||
}
|
||||
_lastUpdateCheck = new DateTime.now();
|
||||
_lastUpdateCheck = DateTime.now();
|
||||
|
||||
final String updateUrl = await widget.updateUrlFetcher();
|
||||
if (updateUrl != null) {
|
||||
@@ -50,17 +50,17 @@ class UpdaterState extends State<Updater> {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final TextStyle dialogTextStyle =
|
||||
theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color);
|
||||
return new AlertDialog(
|
||||
return AlertDialog(
|
||||
title: const Text('Update Flutter Gallery?'),
|
||||
content: new Text('A newer version is available.', style: dialogTextStyle),
|
||||
content: Text('A newer version is available.', style: dialogTextStyle),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('NO THANKS'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, false);
|
||||
},
|
||||
),
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
child: const Text('UPDATE'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, true);
|
||||
|
||||
@@ -6,231 +6,231 @@ void main() {
|
||||
group('All material demos meet recommended tap target sizes', () {
|
||||
testWidgets('backdrop_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new BackdropDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: BackdropDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('bottom_app_bar_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new BottomAppBarDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: BottomAppBarDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('bottom_navigation_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new BottomNavigationDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: BottomNavigationDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('buttons_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new ButtonsDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: ButtonsDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('cards_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new CardsDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: CardsDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('chip_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new ChipDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: ChipDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('data_table_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new DataTableDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: DataTableDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('date_and_time_picker_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new DateAndTimePickerDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: DateAndTimePickerDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
}, skip: true); // https://github.com/flutter/flutter/issues/21578
|
||||
|
||||
testWidgets('dialog_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new DialogDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: DialogDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('drawer_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new DrawerDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: DrawerDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('elevation_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new ElevationDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: ElevationDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('expansion_panels_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new ExpansionPanelsDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: ExpansionPanelsDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('grid_list_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const GridListDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const GridListDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('icons_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new IconsDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: IconsDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('leave_behind_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const LeaveBehindDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const LeaveBehindDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('list_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const ListDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const ListDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('menu_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const MenuDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const MenuDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('modal_bottom_sheet_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new ModalBottomSheetDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: ModalBottomSheetDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('overscroll_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const OverscrollDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const OverscrollDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('page_selector_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new PageSelectorDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: PageSelectorDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('persistent_bottom_sheet_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new PersistentBottomSheetDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: PersistentBottomSheetDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('progress_indicator_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new ProgressIndicatorDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: ProgressIndicatorDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('reorderable_list_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const ReorderableListDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const ReorderableListDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('scrollable_tabs_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new ScrollableTabsDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: ScrollableTabsDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('search_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new SearchDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: SearchDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('selection_controls_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new SelectionControlsDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: SelectionControlsDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('slider_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new SliderDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: SliderDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('snack_bar_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const SnackBarDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const SnackBarDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('tabs_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new TabsDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: TabsDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('tabs_fab_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new TabsFabDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: TabsFabDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('text_form_field_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const TextFormFieldDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const TextFormFieldDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('tooltip_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new TooltipDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: TooltipDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('two_level_list_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new TwoLevelListDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: TwoLevelListDemo()));
|
||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
@@ -239,231 +239,231 @@ void main() {
|
||||
group('All material demos meet text contrast guidelines', () {
|
||||
testWidgets('backdrop_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new BackdropDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: BackdropDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('bottom_app_bar_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new BottomAppBarDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: BottomAppBarDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
}, skip: true); // https://github.com/flutter/flutter/issues/21651
|
||||
|
||||
testWidgets('bottom_navigation_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new BottomNavigationDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: BottomNavigationDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('buttons_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new ButtonsDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: ButtonsDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
}, skip: true); // https://github.com/flutter/flutter/issues/21647
|
||||
|
||||
testWidgets('cards_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new CardsDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: CardsDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
}, skip: true); // https://github.com/flutter/flutter/issues/21651
|
||||
|
||||
testWidgets('chip_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new ChipDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: ChipDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
}, skip: true); // https://github.com/flutter/flutter/issues/21647
|
||||
|
||||
testWidgets('data_table_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new DataTableDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: DataTableDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
}, skip: true); // https://github.com/flutter/flutter/issues/21647
|
||||
|
||||
testWidgets('date_and_time_picker_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new DateAndTimePickerDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: DateAndTimePickerDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
}, skip: true); // https://github.com/flutter/flutter/issues/21647
|
||||
|
||||
testWidgets('dialog_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new DialogDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: DialogDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('drawer_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new DrawerDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: DrawerDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('elevation_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new ElevationDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: ElevationDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('expansion_panels_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new ExpansionPanelsDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: ExpansionPanelsDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('grid_list_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const GridListDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const GridListDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('icons_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new IconsDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: IconsDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
}, skip: true); // https://github.com/flutter/flutter/issues/21647
|
||||
|
||||
testWidgets('leave_behind_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const LeaveBehindDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const LeaveBehindDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('list_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const ListDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const ListDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('menu_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const MenuDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const MenuDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('modal_bottom_sheet_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new ModalBottomSheetDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: ModalBottomSheetDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('overscroll_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const OverscrollDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const OverscrollDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('page_selector_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new PageSelectorDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: PageSelectorDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('persistent_bottom_sheet_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new PersistentBottomSheetDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: PersistentBottomSheetDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('progress_indicator_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new ProgressIndicatorDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: ProgressIndicatorDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('reorderable_list_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const ReorderableListDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const ReorderableListDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('scrollable_tabs_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new ScrollableTabsDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: ScrollableTabsDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('search_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new SearchDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: SearchDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
}, skip: true); // https://github.com/flutter/flutter/issues/21651
|
||||
|
||||
testWidgets('selection_controls_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new SelectionControlsDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: SelectionControlsDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('slider_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new SliderDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: SliderDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('snack_bar_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const SnackBarDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const SnackBarDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('tabs_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new TabsDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: TabsDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('tabs_fab_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new TabsFabDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: TabsFabDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('text_form_field_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: const TextFormFieldDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const TextFormFieldDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('tooltip_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new TooltipDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: TooltipDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('two_level_list_demo', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(home: new TwoLevelListDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: TwoLevelListDemo()));
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
|
||||
|
||||
void main() {
|
||||
test('Test order of operations: 12 + 3 * 4 = 24', () {
|
||||
CalcExpression expression = new CalcExpression.empty();
|
||||
CalcExpression expression = CalcExpression.empty();
|
||||
expression = expression.appendDigit(1);
|
||||
expression = expression.appendDigit(2);
|
||||
expression = expression.appendOperation(Operation.Addition);
|
||||
@@ -21,7 +21,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('Test floating point 0.1 + 0.2 = 0.3', () {
|
||||
CalcExpression expression = new CalcExpression.empty();
|
||||
CalcExpression expression = CalcExpression.empty();
|
||||
expression = expression.appendDigit(0);
|
||||
expression = expression.appendPoint();
|
||||
expression = expression.appendDigit(1);
|
||||
@@ -35,7 +35,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('Test floating point 1.0/10.0 = 0.1', () {
|
||||
CalcExpression expression = new CalcExpression.empty();
|
||||
CalcExpression expression = CalcExpression.empty();
|
||||
expression = expression.appendDigit(1);
|
||||
expression = expression.appendPoint();
|
||||
expression = expression.appendDigit(0);
|
||||
@@ -50,7 +50,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('Test 1/0 = Infinity', () {
|
||||
CalcExpression expression = new CalcExpression.empty();
|
||||
CalcExpression expression = CalcExpression.empty();
|
||||
expression = expression.appendDigit(1);
|
||||
expression = expression.appendOperation(Operation.Division);
|
||||
expression = expression.appendDigit(0);
|
||||
@@ -60,7 +60,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('Test use result in next calculation: 1 + 1 = 2 + 1 = 3 + 1 = 4', () {
|
||||
CalcExpression expression = new CalcExpression.empty();
|
||||
CalcExpression expression = CalcExpression.empty();
|
||||
expression = expression.appendDigit(1);
|
||||
expression = expression.appendOperation(Operation.Addition);
|
||||
expression = expression.appendDigit(1);
|
||||
@@ -76,7 +76,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('Test minus -3 - -2 = -1', () {
|
||||
CalcExpression expression = new CalcExpression.empty();
|
||||
CalcExpression expression = CalcExpression.empty();
|
||||
expression = expression.appendMinus();
|
||||
expression = expression.appendDigit(3);
|
||||
expression = expression.appendMinus();
|
||||
|
||||
@@ -14,7 +14,7 @@ void main() {
|
||||
// We press the "1" and the "2" buttons and check that the display
|
||||
// reads "12".
|
||||
testWidgets('Flutter calculator app smoke test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(new MaterialApp(home: const CalculatorDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const CalculatorDemo()));
|
||||
|
||||
final Finder oneButton = find.widgetWithText(InkResponse, '1');
|
||||
expect(oneButton, findsOneWidget);
|
||||
|
||||
@@ -9,9 +9,9 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
void main() {
|
||||
testWidgets('Chip demo has semantic labels', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(new MaterialApp(
|
||||
theme: new ThemeData(platform: TargetPlatform.iOS),
|
||||
home: new ChipDemo(),
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.iOS),
|
||||
home: ChipDemo(),
|
||||
));
|
||||
|
||||
expect(tester.getSemanticsData(find.byIcon(Icons.vignette)), matchesSemanticsData(
|
||||
|
||||
@@ -8,9 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Drawer header does not scroll', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(new MaterialApp(
|
||||
theme: new ThemeData(platform: TargetPlatform.iOS),
|
||||
home: new DrawerDemo(),
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.iOS),
|
||||
home: DrawerDemo(),
|
||||
));
|
||||
|
||||
await tester.tap(find.text('Tap here to open the drawer'));
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('validates name field correctly', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(new MaterialApp(home: const TextFormFieldDemo()));
|
||||
await tester.pumpWidget(MaterialApp(home: const TextFormFieldDemo()));
|
||||
|
||||
final Finder submitButton = find.widgetWithText(RaisedButton, 'SUBMIT');
|
||||
expect(submitButton, findsOneWidget);
|
||||
|
||||
@@ -16,7 +16,7 @@ void main() {
|
||||
bool hasFeedback = false;
|
||||
|
||||
await tester.pumpWidget(
|
||||
new GalleryApp(
|
||||
GalleryApp(
|
||||
testMode: true,
|
||||
onSendFeedback: () {
|
||||
hasFeedback = true;
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
test('Flutter gallery example code parser test', () async {
|
||||
final TestAssetBundle bundle = new TestAssetBundle();
|
||||
final TestAssetBundle bundle = TestAssetBundle();
|
||||
|
||||
final String codeSnippet0 = await getExampleCode('test_0', bundle);
|
||||
expect(codeSnippet0, 'test 0 0\ntest 0 1');
|
||||
@@ -46,7 +46,7 @@ class TestAssetBundle extends AssetBundle {
|
||||
@override
|
||||
Future<String> loadString(String key, { bool cache = true }) {
|
||||
if (key == 'lib/gallery/example_code.dart')
|
||||
return new Future<String>.value(testCodeFile);
|
||||
return Future<String>.value(testCodeFile);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,14 +44,14 @@ Future<Null> main() async {
|
||||
// Verify that _kUnsynchronizedDemos and _kSkippedDemos identify
|
||||
// demos that actually exist.
|
||||
final List<String> allDemoTitles = kAllGalleryDemos.map((GalleryDemo demo) => demo.title).toList();
|
||||
if (!new Set<String>.from(allDemoTitles).containsAll(_kUnsynchronizedDemoTitles))
|
||||
if (!Set<String>.from(allDemoTitles).containsAll(_kUnsynchronizedDemoTitles))
|
||||
fail('Unrecognized demo titles in _kUnsynchronizedDemosTitles: $_kUnsynchronizedDemoTitles');
|
||||
if (!new Set<String>.from(allDemoTitles).containsAll(_kSkippedDemoTitles))
|
||||
if (!Set<String>.from(allDemoTitles).containsAll(_kSkippedDemoTitles))
|
||||
fail('Unrecognized demo names in _kSkippedDemoTitles: $_kSkippedDemoTitles');
|
||||
|
||||
print('Starting app...');
|
||||
runApp(const GalleryApp(testMode: true));
|
||||
final _LiveWidgetController controller = new _LiveWidgetController(WidgetsBinding.instance);
|
||||
final _LiveWidgetController controller = _LiveWidgetController(WidgetsBinding.instance);
|
||||
for (GalleryDemoCategory category in kAllGalleryDemoCategories) {
|
||||
print('Tapping "${category.name}" section...');
|
||||
await controller.tap(find.text(category.name));
|
||||
@@ -90,7 +90,7 @@ class _LiveWidgetController extends LiveWidgetController {
|
||||
|
||||
/// Waits until at the end of a frame the provided [condition] is [true].
|
||||
Future<Null> _waitUntilFrame(bool condition(), [Completer<Null> completer]) {
|
||||
completer ??= new Completer<Null>();
|
||||
completer ??= Completer<Null>();
|
||||
if (!condition()) {
|
||||
SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) {
|
||||
_waitUntilFrame(condition, completer);
|
||||
|
||||
@@ -137,7 +137,7 @@ Future<Null> smokeGallery(WidgetTester tester) async {
|
||||
bool sendFeedbackButtonPressed = false;
|
||||
|
||||
await tester.pumpWidget(
|
||||
new GalleryApp(
|
||||
GalleryApp(
|
||||
testMode: true,
|
||||
onSendFeedback: () {
|
||||
sendFeedbackButtonPressed = true; // see smokeOptionsPage()
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
|
||||
|
||||
Future<String> mockUpdateUrlFetcher() {
|
||||
// A real implementation would connect to the network to retrieve this value
|
||||
return new Future<String>.value('http://www.example.com/');
|
||||
return Future<String>.value('http://www.example.com/');
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -31,17 +31,17 @@ void main() {
|
||||
// Scroll down
|
||||
for (int i = 0; i < 5; i++) {
|
||||
await driver.scroll(demoList, 0.0, -300.0, const Duration(milliseconds: 300));
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 500));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
// Scroll up
|
||||
for (int i = 0; i < 5; i++) {
|
||||
await driver.scroll(demoList, 0.0, 300.0, const Duration(milliseconds: 300));
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 500));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
});
|
||||
|
||||
new TimelineSummary.summarize(timeline)
|
||||
TimelineSummary.summarize(timeline)
|
||||
..writeSummaryToFile('home_scroll_perf', pretty: true)
|
||||
..writeTimelineToFile('home_scroll_perf', pretty: true);
|
||||
});
|
||||
|
||||
@@ -86,7 +86,7 @@ Future<Null> saveDurationsHistogram(List<Map<String, dynamic>> events, String ou
|
||||
});
|
||||
|
||||
if (unexpectedValueCounts.isNotEmpty) {
|
||||
final StringBuffer error = new StringBuffer('Some routes recorded wrong number of values (expected 2 values/route):\n\n');
|
||||
final StringBuffer error = StringBuffer('Some routes recorded wrong number of values (expected 2 values/route):\n\n');
|
||||
unexpectedValueCounts.forEach((String routeName, int count) {
|
||||
error.writeln(' - $routeName recorded $count values.');
|
||||
});
|
||||
@@ -183,7 +183,7 @@ void main([List<String> args = const <String>[]]) {
|
||||
}
|
||||
|
||||
// See _handleMessages() in transitions_perf.dart.
|
||||
_allDemos = new List<String>.from(const JsonDecoder().convert(await driver.requestData('demoNames')));
|
||||
_allDemos = List<String>.from(const JsonDecoder().convert(await driver.requestData('demoNames')));
|
||||
if (_allDemos.isEmpty)
|
||||
throw 'no demo names found';
|
||||
});
|
||||
@@ -209,15 +209,15 @@ void main([List<String> args = const <String>[]]) {
|
||||
// Save the duration (in microseconds) of the first timeline Frame event
|
||||
// that follows a 'Start Transition' event. The Gallery app adds a
|
||||
// 'Start Transition' event when a demo is launched (see GalleryItem).
|
||||
final TimelineSummary summary = new TimelineSummary.summarize(timeline);
|
||||
final TimelineSummary summary = TimelineSummary.summarize(timeline);
|
||||
await summary.writeSummaryToFile('transitions', pretty: true);
|
||||
final String histogramPath = path.join(testOutputsDirectory, 'transition_durations.timeline.json');
|
||||
await saveDurationsHistogram(
|
||||
new List<Map<String, dynamic>>.from(timeline.json['traceEvents']),
|
||||
List<Map<String, dynamic>>.from(timeline.json['traceEvents']),
|
||||
histogramPath);
|
||||
|
||||
// Execute the remaining tests.
|
||||
final Set<String> unprofiledDemos = new Set<String>.from(_allDemos)..removeAll(kProfiledDemos);
|
||||
final Set<String> unprofiledDemos = Set<String>.from(_allDemos)..removeAll(kProfiledDemos);
|
||||
await runDemos(unprofiledDemos.toList(), driver);
|
||||
|
||||
}, timeout: const Timeout(Duration(minutes: 5)));
|
||||
|
||||
@@ -30,7 +30,7 @@ class LifecycleObserver extends WidgetsBindingObserver {
|
||||
Future<void> main() async {
|
||||
runApp(const GalleryApp());
|
||||
await endOfAnimation();
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 50));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 50));
|
||||
debugPrint('==== MEMORY BENCHMARK ==== READY ====');
|
||||
WidgetsBinding.instance.addObserver(new LifecycleObserver());
|
||||
WidgetsBinding.instance.addObserver(LifecycleObserver());
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ Rect boundsFor(WidgetController controller, Finder item) {
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
final Completer<void> ready = new Completer<void>();
|
||||
runApp(new GestureDetector(
|
||||
final Completer<void> ready = Completer<void>();
|
||||
runApp(GestureDetector(
|
||||
onTap: () {
|
||||
debugPrint('Received tap.');
|
||||
ready.complete();
|
||||
@@ -36,14 +36,14 @@ Future<void> main() async {
|
||||
),
|
||||
));
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 50));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 50));
|
||||
debugPrint('==== MEMORY BENCHMARK ==== READY ====');
|
||||
|
||||
await ready.future;
|
||||
debugPrint('Continuing...');
|
||||
|
||||
// remove onTap handler, enable pointer events for app
|
||||
runApp(new GestureDetector(
|
||||
runApp(GestureDetector(
|
||||
child: const IgnorePointer(
|
||||
ignoring: false,
|
||||
child: GalleryApp(testMode: true),
|
||||
@@ -51,16 +51,16 @@ Future<void> main() async {
|
||||
));
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
|
||||
final WidgetController controller = new LiveWidgetController(WidgetsBinding.instance);
|
||||
final WidgetController controller = LiveWidgetController(WidgetsBinding.instance);
|
||||
|
||||
debugPrint('Navigating...');
|
||||
await controller.tap(find.text('Material'));
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 150));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 150));
|
||||
final Finder demoList = find.byKey(const Key('GalleryDemoList'));
|
||||
final Finder demoItem = find.text('Text fields');
|
||||
do {
|
||||
await controller.drag(demoList, const Offset(0.0, -300.0));
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 20));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 20));
|
||||
} while (!demoItem.precache());
|
||||
|
||||
// Ensure that the center of the "Text fields" item is visible
|
||||
@@ -68,7 +68,7 @@ Future<void> main() async {
|
||||
final Rect demoItemBounds = boundsFor(controller, demoItem);
|
||||
final Rect demoListBounds = boundsFor(controller, demoList);
|
||||
if (!demoListBounds.contains(demoItemBounds.center)) {
|
||||
await controller.drag(demoList, new Offset(0.0, demoListBounds.center.dy - demoItemBounds.center.dy));
|
||||
await controller.drag(demoList, Offset(0.0, demoListBounds.center.dy - demoItemBounds.center.dy));
|
||||
await endOfAnimation();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,26 +7,26 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
void main() {
|
||||
runApp(new FlutterView());
|
||||
runApp(FlutterView());
|
||||
}
|
||||
|
||||
class FlutterView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
return MaterialApp(
|
||||
title: 'Flutter View',
|
||||
theme: new ThemeData(
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.grey,
|
||||
),
|
||||
home: new MyHomePage(),
|
||||
home: MyHomePage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
@override
|
||||
_MyHomePageState createState() => new _MyHomePageState();
|
||||
_MyHomePageState createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
@@ -57,29 +57,29 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
body: new Column(
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
child: new Center(
|
||||
child: new Text(
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Platform button tapped $_counter time${ _counter == 1 ? '' : 's' }.',
|
||||
style: const TextStyle(fontSize: 17.0))
|
||||
),
|
||||
),
|
||||
new Container(
|
||||
Container(
|
||||
padding: const EdgeInsets.only(bottom: 15.0, left: 5.0),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Image.asset('assets/flutter-mark-square-64.png', scale: 1.5),
|
||||
Image.asset('assets/flutter-mark-square-64.png', scale: 1.5),
|
||||
const Text('Flutter', style: TextStyle(fontSize: 30.0)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: _sendFlutterIncrement,
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
|
||||
@@ -13,17 +13,17 @@ ui.Picture paint(ui.Rect paintBounds) {
|
||||
// First we create a PictureRecorder to record the commands we're going to
|
||||
// feed in the canvas. The PictureRecorder will eventually produce a Picture,
|
||||
// which is an immutable record of those commands.
|
||||
final ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||
final ui.PictureRecorder recorder = ui.PictureRecorder();
|
||||
|
||||
// Next, we create a canvas from the recorder. The canvas is an interface
|
||||
// which can receive drawing commands. The canvas interface is modeled after
|
||||
// the SkCanvas interface from Skia. The paintBounds establishes a "cull rect"
|
||||
// for the canvas, which lets the implementation discard any commands that
|
||||
// are entirely outside this rectangle.
|
||||
final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||
final ui.Canvas canvas = ui.Canvas(recorder, paintBounds);
|
||||
|
||||
final ui.Paint paint = new ui.Paint();
|
||||
canvas.drawPaint(new ui.Paint()..color = const ui.Color(0xFFFFFFFF));
|
||||
final ui.Paint paint = ui.Paint();
|
||||
canvas.drawPaint(ui.Paint()..color = const ui.Color(0xFFFFFFFF));
|
||||
|
||||
final ui.Size size = paintBounds.size;
|
||||
final ui.Offset mid = size.center(ui.Offset.zero);
|
||||
@@ -34,22 +34,22 @@ ui.Picture paint(ui.Rect paintBounds) {
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(-mid.dx / 2.0, logicalSize.height * 2.0);
|
||||
canvas.clipRect(new ui.Rect.fromLTRB(0.0, -logicalSize.height, logicalSize.width, radius));
|
||||
canvas.clipRect(ui.Rect.fromLTRB(0.0, -logicalSize.height, logicalSize.width, radius));
|
||||
|
||||
canvas.translate(mid.dx, mid.dy);
|
||||
paint.color = const ui.Color.fromARGB(128, 255, 0, 255);
|
||||
canvas.rotate(math.pi/4.0);
|
||||
|
||||
final ui.Gradient yellowBlue = new ui.Gradient.linear(
|
||||
new ui.Offset(-radius, -radius),
|
||||
final ui.Gradient yellowBlue = ui.Gradient.linear(
|
||||
ui.Offset(-radius, -radius),
|
||||
const ui.Offset(0.0, 0.0),
|
||||
<ui.Color>[const ui.Color(0xFFFFFF00), const ui.Color(0xFF0000FF)],
|
||||
);
|
||||
canvas.drawRect(new ui.Rect.fromLTRB(-radius, -radius, radius, radius),
|
||||
new ui.Paint()..shader = yellowBlue);
|
||||
canvas.drawRect(ui.Rect.fromLTRB(-radius, -radius, radius, radius),
|
||||
ui.Paint()..shader = yellowBlue);
|
||||
|
||||
// Scale x and y by 0.5.
|
||||
final Float64List scaleMatrix = new Float64List.fromList(<double>[
|
||||
final Float64List scaleMatrix = Float64List.fromList(<double>[
|
||||
0.5, 0.0, 0.0, 0.0,
|
||||
0.0, 0.5, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
@@ -72,12 +72,12 @@ ui.Picture paint(ui.Rect paintBounds) {
|
||||
|
||||
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||
final Float64List deviceTransform = new Float64List(16)
|
||||
final Float64List deviceTransform = Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder()
|
||||
final ui.SceneBuilder sceneBuilder = ui.SceneBuilder()
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
|
||||
@@ -11,24 +11,24 @@ void beginFrame(Duration timeStamp) {
|
||||
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||
final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio;
|
||||
|
||||
final ui.ParagraphBuilder paragraphBuilder = new ui.ParagraphBuilder(
|
||||
new ui.ParagraphStyle(textDirection: ui.TextDirection.ltr),
|
||||
final ui.ParagraphBuilder paragraphBuilder = ui.ParagraphBuilder(
|
||||
ui.ParagraphStyle(textDirection: ui.TextDirection.ltr),
|
||||
)
|
||||
..addText('Hello, world.');
|
||||
final ui.Paragraph paragraph = paragraphBuilder.build()
|
||||
..layout(new ui.ParagraphConstraints(width: logicalSize.width));
|
||||
..layout(ui.ParagraphConstraints(width: logicalSize.width));
|
||||
|
||||
final ui.Rect physicalBounds = ui.Offset.zero & (logicalSize * devicePixelRatio);
|
||||
final ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||
final ui.Canvas canvas = new ui.Canvas(recorder, physicalBounds);
|
||||
final ui.PictureRecorder recorder = ui.PictureRecorder();
|
||||
final ui.Canvas canvas = ui.Canvas(recorder, physicalBounds);
|
||||
canvas.scale(devicePixelRatio, devicePixelRatio);
|
||||
canvas.drawParagraph(paragraph, new ui.Offset(
|
||||
canvas.drawParagraph(paragraph, ui.Offset(
|
||||
(logicalSize.width - paragraph.maxIntrinsicWidth) / 2.0,
|
||||
(logicalSize.height - paragraph.height) / 2.0
|
||||
));
|
||||
final ui.Picture picture = recorder.endRecording();
|
||||
|
||||
final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder()
|
||||
final ui.SceneBuilder sceneBuilder = ui.SceneBuilder()
|
||||
// TODO(abarth): We should be able to add a picture without pushing a
|
||||
// container layer first.
|
||||
..pushClipRect(physicalBounds)
|
||||
|
||||
@@ -20,8 +20,8 @@ void beginFrame(Duration timeStamp) {
|
||||
// PAINT
|
||||
|
||||
final ui.Rect paintBounds = ui.Offset.zero & (ui.window.physicalSize / ui.window.devicePixelRatio);
|
||||
final ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||
final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||
final ui.PictureRecorder recorder = ui.PictureRecorder();
|
||||
final ui.Canvas canvas = ui.Canvas(recorder, paintBounds);
|
||||
canvas.translate(paintBounds.width / 2.0, paintBounds.height / 2.0);
|
||||
|
||||
// Here we determine the rotation according to the timeStamp given to us by
|
||||
@@ -29,19 +29,19 @@ void beginFrame(Duration timeStamp) {
|
||||
final double t = timeStamp.inMicroseconds / Duration.microsecondsPerMillisecond / 1800.0;
|
||||
canvas.rotate(math.pi * (t % 1.0));
|
||||
|
||||
canvas.drawRect(new ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
|
||||
new ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0));
|
||||
canvas.drawRect(ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
|
||||
ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0));
|
||||
final ui.Picture picture = recorder.endRecording();
|
||||
|
||||
// COMPOSITE
|
||||
|
||||
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||
final Float64List deviceTransform = new Float64List(16)
|
||||
final Float64List deviceTransform = Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder()
|
||||
final ui.SceneBuilder sceneBuilder = ui.SceneBuilder()
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
|
||||
@@ -12,31 +12,31 @@ import 'dart:ui' as ui;
|
||||
ui.Paragraph paragraph;
|
||||
|
||||
ui.Picture paint(ui.Rect paintBounds) {
|
||||
final ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||
final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||
final ui.PictureRecorder recorder = ui.PictureRecorder();
|
||||
final ui.Canvas canvas = ui.Canvas(recorder, paintBounds);
|
||||
|
||||
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||
final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio;
|
||||
|
||||
canvas.translate(logicalSize.width / 2.0, logicalSize.height / 2.0);
|
||||
canvas.drawRect(new ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
|
||||
new ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0));
|
||||
canvas.drawRect(ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
|
||||
ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0));
|
||||
|
||||
// The paint method of Paragraph draws the contents of the paragraph onto the
|
||||
// given canvas.
|
||||
canvas.drawParagraph(paragraph, new ui.Offset(-paragraph.width / 2.0, (paragraph.width / 2.0) - 125.0));
|
||||
canvas.drawParagraph(paragraph, ui.Offset(-paragraph.width / 2.0, (paragraph.width / 2.0) - 125.0));
|
||||
|
||||
return recorder.endRecording();
|
||||
}
|
||||
|
||||
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||
final Float64List deviceTransform = new Float64List(16)
|
||||
final Float64List deviceTransform = Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder()
|
||||
final ui.SceneBuilder sceneBuilder = ui.SceneBuilder()
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
@@ -52,18 +52,18 @@ void beginFrame(Duration timeStamp) {
|
||||
|
||||
void main() {
|
||||
// To create a paragraph of text, we use ParagraphBuilder.
|
||||
final ui.ParagraphBuilder builder = new ui.ParagraphBuilder(
|
||||
final ui.ParagraphBuilder builder = ui.ParagraphBuilder(
|
||||
// The text below has a primary direction of left-to-right.
|
||||
// The embedded text has other directions.
|
||||
// If this was TextDirection.rtl, the "Hello, world" text would end up on
|
||||
// the other side of the right-to-left text.
|
||||
new ui.ParagraphStyle(textDirection: ui.TextDirection.ltr),
|
||||
ui.ParagraphStyle(textDirection: ui.TextDirection.ltr),
|
||||
)
|
||||
// We first push a style that turns the text blue.
|
||||
..pushStyle(new ui.TextStyle(color: const ui.Color(0xFF0000FF)))
|
||||
..pushStyle(ui.TextStyle(color: const ui.Color(0xFF0000FF)))
|
||||
..addText('Hello, ')
|
||||
// The next run of text will be bold.
|
||||
..pushStyle(new ui.TextStyle(fontWeight: ui.FontWeight.bold))
|
||||
..pushStyle(ui.TextStyle(fontWeight: ui.FontWeight.bold))
|
||||
..addText('world. ')
|
||||
// The pop() command signals the end of the bold styling.
|
||||
..pop()
|
||||
@@ -84,7 +84,7 @@ void main() {
|
||||
// Next, we supply a width that the text is permitted to occupy and we ask
|
||||
// the paragraph to the visual position of each its glyphs as well as its
|
||||
// overall size, subject to its sizing constraints.
|
||||
..layout(new ui.ParagraphConstraints(width: 180.0));
|
||||
..layout(ui.ParagraphConstraints(width: 180.0));
|
||||
|
||||
// Finally, we register our beginFrame callback and kick off the first frame.
|
||||
ui.window.onBeginFrame = beginFrame;
|
||||
|
||||
@@ -14,21 +14,21 @@ ui.Picture paint(ui.Rect paintBounds) {
|
||||
// First we create a PictureRecorder to record the commands we're going to
|
||||
// feed in the canvas. The PictureRecorder will eventually produce a Picture,
|
||||
// which is an immutable record of those commands.
|
||||
final ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||
final ui.PictureRecorder recorder = ui.PictureRecorder();
|
||||
|
||||
// Next, we create a canvas from the recorder. The canvas is an interface
|
||||
// which can receive drawing commands. The canvas interface is modeled after
|
||||
// the SkCanvas interface from Skia. The paintBounds establishes a "cull rect"
|
||||
// for the canvas, which lets the implementation discard any commands that
|
||||
// are entirely outside this rectangle.
|
||||
final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||
final ui.Canvas canvas = ui.Canvas(recorder, paintBounds);
|
||||
|
||||
// The commands draw a circle in the center of the screen.
|
||||
final ui.Size size = paintBounds.size;
|
||||
canvas.drawCircle(
|
||||
size.center(ui.Offset.zero),
|
||||
size.shortestSide * 0.45,
|
||||
new ui.Paint()..color = color
|
||||
ui.Paint()..color = color
|
||||
);
|
||||
|
||||
// When we're done issuing painting commands, we end the recording an receive
|
||||
@@ -46,7 +46,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||
|
||||
// This transform scales the x and y coordinates by the devicePixelRatio.
|
||||
final Float64List deviceTransform = new Float64List(16)
|
||||
final Float64List deviceTransform = Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
@@ -56,7 +56,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
// transform that scale its children by the device pixel ratio. This transform
|
||||
// lets us paint in "logical" pixels which are converted to device pixels by
|
||||
// this scaling operation.
|
||||
final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder()
|
||||
final ui.SceneBuilder sceneBuilder = ui.SceneBuilder()
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user