main.dart 5.4 KB

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