main.dart 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/services.dart';
  3. void main() {
  4. runApp(const MyApp());
  5. }
  6. class MyApp extends StatelessWidget {
  7. const MyApp({super.key});
  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 THIS: Try running your application with "flutter run". You'll see
  17. // the application has a blue toolbar. Then, without quitting the app,
  18. // try changing the seedColor in the colorScheme below to Colors.green
  19. // and then invoke "hot reload" (save your changes or press the "hot
  20. // reload" button in a Flutter-supported IDE, or press "r" if you used
  21. // the command line to start the app).
  22. //
  23. // Notice that the counter didn't reset back to zero; the application
  24. // state is not lost during the reload. To reset the state, use hot
  25. // restart instead.
  26. //
  27. // This works for code too, not just values: Most code changes can be
  28. // tested with just a hot reload.
  29. colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
  30. useMaterial3: true,
  31. ),
  32. home: const MyHomePage(title: 'Flutter Demo Home Page'),
  33. );
  34. }
  35. }
  36. class MyHomePage extends StatefulWidget {
  37. const MyHomePage({super.key, required this.title});
  38. // This widget is the home page of your application. It is stateful, meaning
  39. // that it has a State object (defined below) that contains fields that affect
  40. // how it looks.
  41. // This class is the configuration for the state. It holds the values (in this
  42. // case the title) provided by the parent (in this case the App widget) and
  43. // used by the build method of the State. Fields in a Widget subclass are
  44. // always marked "final".
  45. final String title;
  46. @override
  47. State<MyHomePage> createState() => _MyHomePageState();
  48. }
  49. class _MyHomePageState extends State<MyHomePage> {
  50. static const nativeChannel = MethodChannel("nativeChannel");
  51. int _counter = 0;
  52. void _incrementCounter() {
  53. setState(() {
  54. // This call to setState tells the Flutter framework that something has
  55. // changed in this State, which causes it to rerun the build method below
  56. // so that the display can reflect the updated values. If we changed
  57. // _counter without calling setState(), then the build method would not be
  58. // called again, and so nothing would appear to happen.
  59. _counter++;
  60. });
  61. }
  62. @override
  63. Widget build(BuildContext context) {
  64. // This method is rerun every time setState is called, for instance as done
  65. // by the _incrementCounter method above.
  66. //
  67. // The Flutter framework has been optimized to make rerunning build methods
  68. // fast, so that you can just rebuild anything that needs updating rather
  69. // than having to individually change instances of widgets.
  70. return Scaffold(
  71. appBar: AppBar(
  72. // TRY THIS: Try changing the color here to a specific color (to
  73. // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
  74. // change color while the other colors stay the same.
  75. backgroundColor: Theme.of(context).colorScheme.inversePrimary,
  76. // Here we take the value from the MyHomePage object that was created by
  77. // the App.build method, and use it to set our appbar title.
  78. title: Text(widget.title),
  79. actions: <Widget>[
  80. PopupMenuButton<String>(
  81. onSelected: handleClick,
  82. itemBuilder: (BuildContext context) {
  83. return {
  84. 'Features List'
  85. }.map((String choice) {
  86. return PopupMenuItem<String>(
  87. value: choice,
  88. child: Text(choice),
  89. );
  90. }).toList();
  91. },
  92. ),
  93. ],
  94. ),
  95. body: Center(
  96. // Center is a layout widget. It takes a single child and positions it
  97. // in the middle of the parent.
  98. child: Column(
  99. // Column is also a layout widget. It takes a list of children and
  100. // arranges them vertically. By default, it sizes itself to fit its
  101. // children horizontally, and tries to be as tall as its parent.
  102. //
  103. // Column has various properties to control how it sizes itself and
  104. // how it positions its children. Here we use mainAxisAlignment to
  105. // center the children vertically; the main axis here is the vertical
  106. // axis because Columns are vertical (the cross axis would be
  107. // horizontal).
  108. //
  109. // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
  110. // action in the IDE, or press "p" in the console), to see the
  111. // wireframe for each widget.
  112. mainAxisAlignment: MainAxisAlignment.center,
  113. children: <Widget>[
  114. const Text(
  115. 'You have pushed the button this many times:',
  116. ),
  117. Text(
  118. '$_counter',
  119. style: Theme.of(context).textTheme.headlineMedium,
  120. ),
  121. ],
  122. ),
  123. ),
  124. floatingActionButton: FloatingActionButton(
  125. onPressed: _incrementCounter,
  126. tooltip: 'Increment',
  127. child: const Icon(Icons.add),
  128. ), // This trailing comma makes auto-formatting nicer for build methods.
  129. );
  130. }
  131. void handleClick(String value) async {
  132. switch (value) {
  133. //FEATURES
  134. }
  135. }
  136. }