Merge pull request #1207 from sethladd/new-starter-app

starter app now has a button that does something
This commit is contained in:
Seth Ladd
2016-01-12 10:56:42 -08:00

View File

@@ -201,14 +201,27 @@ void main() {
runApp(
new MaterialApp(
title: "Flutter Demo",
routes: {
routes: <String, RouteBuilder>{
'/': (RouteArguments args) => new FlutterDemo()
}
)
);
}
class FlutterDemo extends StatelessComponent {
class FlutterDemo extends StatefulComponent {
@override
State createState() => new FlutterDemoState();
}
class FlutterDemoState extends State {
int counter = 0;
void incrementCounter() {
setState(() {
counter++;
});
}
Widget build(BuildContext context) {
return new Scaffold(
toolBar: new ToolBar(
@@ -216,13 +229,14 @@ class FlutterDemo extends StatelessComponent {
),
body: new Material(
child: new Center(
child: new Text("Hello world!")
child: new Text("Button tapped $counter times.")
)
),
floatingActionButton: new FloatingActionButton(
child: new Icon(
icon: 'content/add'
)
),
onPressed: incrementCounter
)
);
}