main.dart 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import 'package:cool_ui_example/cool_u_i_example_icons.dart';
  2. import 'package:cool_ui_example/pages/PaintEventDemo.dart';
  3. import 'package:cool_ui_example/pages/PopoverDemo.dart';
  4. import 'package:flutter/material.dart';
  5. void main() => runApp(MyApp());
  6. class MyApp extends StatelessWidget {
  7. // This widget is the root of your application.
  8. @override
  9. Widget build(BuildContext context) {
  10. return MaterialApp(
  11. title: 'Flutter Demo',
  12. theme: ThemeData(
  13. // This is the theme of your application.
  14. //
  15. // Try running your application with "flutter run". You'll see the
  16. // application has a blue toolbar. Then, without quitting the app, try
  17. // changing the primarySwatch below to Colors.green and then invoke
  18. // "hot reload" (press "r" in the console where you ran "flutter run",
  19. // or press Run > Flutter Hot Reload in IntelliJ). Notice that the
  20. // counter didn't reset back to zero; the application is not restarted.
  21. primarySwatch: Colors.blue
  22. ),
  23. home: MyHomePage(title: 'Flutter Demo Home Page'),
  24. );
  25. }
  26. }
  27. class MyHomePage extends StatefulWidget {
  28. MyHomePage({Key key, this.title}) : super(key: key);
  29. // This widget is the home page of your application. It is stateful, meaning
  30. // that it has a State object (defined below) that contains fields that affect
  31. // how it looks.
  32. // This class is the configuration for the state. It holds the values (in this
  33. // case the title) provided by the parent (in this case the App widget) and
  34. // used by the build method of the State. Fields in a Widget subclass are
  35. // always marked "final".
  36. final String title;
  37. @override
  38. _MyHomePageState createState() => _MyHomePageState();
  39. }
  40. class _MyHomePageState extends State<MyHomePage> {
  41. int _counter = 0;
  42. void _incrementCounter() {
  43. setState(() {
  44. // This call to setState tells the Flutter framework that something has
  45. // changed in this State, which causes it to rerun the build method below
  46. // so that the display can reflect the updated values. If we changed
  47. // _counter without calling setState(), then the build method would not be
  48. // called again, and so nothing would appear to happen.
  49. _counter++;
  50. });
  51. }
  52. @override
  53. Widget build(BuildContext context) {
  54. // This method is rerun every time setState is called, for instance as done
  55. // by the _incrementCounter method above.
  56. //
  57. // The Flutter framework has been optimized to make rerunning build methods
  58. // fast, so that you can just rebuild anything that needs updating rather
  59. // than having to individually change instances of widgets.
  60. return Scaffold(
  61. appBar: AppBar(
  62. // Here we take the value from the MyHomePage object that was created by
  63. // the App.build method, and use it to set our appbar title.
  64. title: Text(widget.title),
  65. ),
  66. body: ListView(
  67. children: <Widget>[
  68. ListTile(
  69. leading: Icon(CoolUIExampleIcon.popover),
  70. title: Text("Popover"),
  71. onTap: (){
  72. Navigator.of(context).push(MaterialPageRoute(builder: (context)=>PopoverDemo()));
  73. },
  74. ),
  75. ListTile(
  76. title: Text("PaintEvent"),
  77. onTap: (){
  78. Navigator.of(context).push(MaterialPageRoute(builder: (context)=>PaintEventDemo()));
  79. },
  80. )
  81. ],
  82. )
  83. );
  84. }
  85. }