main.dart.tmpl 1.23 KB
Newer Older
1
import 'package:flutter/material.dart';
2 3 4
{{#withDriverTest?}}
import 'package:flutter_driver/driver_extension.dart';
{{/withDriverTest?}}
5 6

void main() {
7 8 9 10 11
{{#withDriverTest?}}
  // Starts the app with Flutter Driver extension enabled to allow Flutter Driver
  // to test the app.
  enableFlutterDriverExtension();
{{/withDriverTest?}}
12 13 14
  runApp(
    new MaterialApp(
      title: 'Flutter Demo',
15 16
      routes: <String, WidgetBuilder>{
        '/': (BuildContext context) => new FlutterDemo()
17 18 19 20 21
      }
    )
  );
}

22
class FlutterDemo extends StatefulWidget {
23
  @override
Adam Barth's avatar
Adam Barth committed
24
  _FlutterDemoState createState() => new _FlutterDemoState();
25 26 27 28 29 30 31 32 33 34 35
}

class _FlutterDemoState extends State<FlutterDemo> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

36
  @override
37 38
  Widget build(BuildContext context) {
    return new Scaffold(
39 40
      appBar: new AppBar(
        title: new Text('Flutter Demo')
41 42
      ),
      body: new Center(
Adam Barth's avatar
Adam Barth committed
43
        child: new Text('Button tapped $_counter time${ _counter == 1 ? '' : 's' }.')
44 45
      ),
      floatingActionButton: new FloatingActionButton(
Adam Barth's avatar
Adam Barth committed
46 47
        onPressed: _incrementCounter,
        tooltip: 'Increment',
48
        child: new Icon(
49
          icon: Icons.add
Adam Barth's avatar
Adam Barth committed
50
        )
51 52 53 54
      )
    );
  }
}