main.dart 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 {'Features List'}
  84. .map((String choice) {
  85. return PopupMenuItem<String>(
  86. value: choice,
  87. child: Text(choice),
  88. );
  89. }).toList();
  90. },
  91. ),
  92. ],
  93. ),
  94. body: Center(
  95. // Center is a layout widget. It takes a single child and positions it
  96. // in the middle of the parent.
  97. child: Column(
  98. // Column is also a layout widget. It takes a list of children and
  99. // arranges them vertically. By default, it sizes itself to fit its
  100. // children horizontally, and tries to be as tall as its parent.
  101. //
  102. // Column has various properties to control how it sizes itself and
  103. // how it positions its children. Here we use mainAxisAlignment to
  104. // center the children vertically; the main axis here is the vertical
  105. // axis because Columns are vertical (the cross axis would be
  106. // horizontal).
  107. //
  108. // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
  109. // action in the IDE, or press "p" in the console), to see the
  110. // wireframe for each widget.
  111. mainAxisAlignment: MainAxisAlignment.center,
  112. children: <Widget>[
  113. const Text(
  114. 'You have pushed the button this many times:',
  115. ),
  116. Text(
  117. '$_counter',
  118. style: Theme.of(context).textTheme.headlineMedium,
  119. ),
  120. ],
  121. ),
  122. ),
  123. floatingActionButton: FloatingActionButton(
  124. onPressed: _incrementCounter,
  125. tooltip: 'Increment',
  126. child: const Icon(Icons.add),
  127. ), // This trailing comma makes auto-formatting nicer for build methods.
  128. );
  129. }
  130. void handleClick(String value) async {
  131. switch (value) {
  132. //FEATURES
  133. }
  134. }
  135. }