main.dart 3.6 KB

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