main.dart 3.1 KB

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