main.dart.tmpl 1.27 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 17
      theme: new ThemeData(
        primarySwatch: Colors.blue
      ),
18
      home: new FlutterDemo()
19 20 21 22
    )
  );
}

23
class FlutterDemo extends StatefulWidget {
24 25
  FlutterDemo({ Key key }) : super(key: key);

26
  @override
Adam Barth's avatar
Adam Barth committed
27
  _FlutterDemoState createState() => new _FlutterDemoState();
28 29 30 31 32 33 34 35 36 37 38
}

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

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

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