Guest User

Untitled

a guest
Feb 17th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() => runApp(MyApp());
  4.  
  5. class MyApp extends StatelessWidget {
  6. @override
  7. Widget build(BuildContext context) {
  8. return MaterialApp(
  9. title: 'Flutter Demo',
  10. theme: ThemeData(
  11. primarySwatch: Colors.blue,
  12. ),
  13. home: MyHomePage(title: 'Flutter Demo Home Page'),
  14. );
  15. }
  16. }
  17.  
  18. class MyHomePage extends StatefulWidget {
  19. MyHomePage({Key key, this.title}) : super(key: key);
  20.  
  21.  
  22. final String title;
  23.  
  24. @override
  25. _MyHomePageState createState() => _MyHomePageState();
  26. }
  27.  
  28. class _MyHomePageState extends State<MyHomePage> {
  29. int _counter = 0;
  30.  
  31. void _incrementCounter() {
  32. setState(() {
  33. _counter++;
  34. });
  35. }
  36.  
  37. @override
  38. Widget build(BuildContext context) {
  39. return Scaffold(
  40. appBar: AppBar(
  41. title: Text(widget.title),
  42. ),
  43. body: Center(
  44. child: Column(
  45. mainAxisAlignment: MainAxisAlignment.center,
  46. children: <Widget>[
  47. Text(
  48. 'You have pushed the button this many times:',
  49. ),
  50. Text(
  51. '$_counter',
  52. style: Theme.of(context).textTheme.display1,
  53. ),
  54. ],
  55. ),
  56. ),
  57. floatingActionButton: FloatingActionButton(
  58. onPressed: _incrementCounter,
  59. tooltip: 'Increment',
  60. child: Icon(Icons.add),
  61. ),
  62. );
  63. }
  64. }
Add Comment
Please, Sign In to add comment