main.dart.tmpl 1.21 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 15 16 17 18 19 20 21 22
  runApp(
    new MaterialApp(
      title: 'Flutter Demo',
      routes: <String, RouteBuilder>{
        '/': (RouteArguments args) => new FlutterDemo()
      }
    )
  );
}

class FlutterDemo extends StatefulComponent {
Adam Barth's avatar
Adam Barth committed
23
  _FlutterDemoState createState() => new _FlutterDemoState();
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
}

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

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

  Widget build(BuildContext context) {
    return new Scaffold(
      toolBar: new ToolBar(
        center: new Text('Flutter Demo')
      ),
      body: new Center(
Adam Barth's avatar
Adam Barth committed
41
        child: new Text('Button tapped $_counter time${ _counter == 1 ? '' : 's' }.')
42 43
      ),
      floatingActionButton: new FloatingActionButton(
Adam Barth's avatar
Adam Barth committed
44 45
        onPressed: _incrementCounter,
        tooltip: 'Increment',
46
        child: new Icon(
47
          icon: Icons.add
Adam Barth's avatar
Adam Barth committed
48
        )
49 50 51 52
      )
    );
  }
}