
Anywhere that accepted IconData now accepts either an Icon or an ImageIcon. Places that used to take an IconData in an `icon` argument, notably IconButton and DrawerItem, now take a Widget in that slot. You can wrap the value that used to be passed in in an Icon constructor to get the same result. Icon itself now takes the icon as a positional argument, for brevity. ThemeData now has an iconTheme as well as a primaryIconTheme, the same way it has had a textTheme and primaryTextTheme for a while. IconTheme.of() always returns a value now (though that value itself may have nulls in it). It defaults to the ThemeData.iconTheme. IconThemeData.fallback() is a new method that returns an icon theme data structure with all fields filled in. IconTheme.merge() is a new constructor that takes a context and creates a widget that mixes in the new values with the inherited values. Most places that introduced an IconTheme widget now use IconTheme.merge. IconThemeData.merge and IconThemeData.copyWith act in a way analogous to the similarly-named members of TextStyle. ImageIcon is introduced. It acts like Icon but takes an ImageProvider instead of an IconData. Also: Fix the analyzer to actually check the stocks app.
56 lines
1.2 KiB
Cheetah
56 lines
1.2 KiB
Cheetah
import 'package:flutter/material.dart';
|
|
{{#withDriverTest?}}
|
|
import 'package:flutter_driver/driver_extension.dart';
|
|
{{/withDriverTest?}}
|
|
|
|
void main() {
|
|
{{#withDriverTest?}}
|
|
// Starts the app with Flutter Driver extension enabled to allow Flutter Driver
|
|
// to test the app.
|
|
enableFlutterDriverExtension();
|
|
{{/withDriverTest?}}
|
|
runApp(
|
|
new MaterialApp(
|
|
title: 'Flutter Demo',
|
|
theme: new ThemeData(
|
|
primarySwatch: Colors.blue
|
|
),
|
|
home: new FlutterDemo()
|
|
)
|
|
);
|
|
}
|
|
|
|
class FlutterDemo extends StatefulWidget {
|
|
FlutterDemo({ Key key }) : super(key: key);
|
|
|
|
@override
|
|
_FlutterDemoState createState() => new _FlutterDemoState();
|
|
}
|
|
|
|
class _FlutterDemoState extends State<FlutterDemo> {
|
|
int _counter = 0;
|
|
|
|
void _incrementCounter() {
|
|
setState(() {
|
|
_counter++;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return new Scaffold(
|
|
appBar: new AppBar(
|
|
title: new Text('Flutter Demo')
|
|
),
|
|
body: new Center(
|
|
child: new Text('Button tapped $_counter time${ _counter == 1 ? '' : 's' }.')
|
|
),
|
|
floatingActionButton: new FloatingActionButton(
|
|
onPressed: _incrementCounter,
|
|
tooltip: 'Increment',
|
|
child: new Icon(Icons.add)
|
|
)
|
|
);
|
|
}
|
|
}
|