main.dart 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import 'package:deus_app/page/device/device_manage_page.dart';
  2. import 'package:deus_app/page/home/home_page.dart';
  3. import 'package:deus_app/page/login/login_page.dart';
  4. import 'package:deus_app/page/patrol/patrol_job_page.dart';
  5. import 'package:flutter/material.dart';
  6. void main() {
  7. runApp(const MyApp());
  8. }
  9. class MyApp extends StatelessWidget {
  10. const MyApp({super.key});
  11. // This widget is the root of your application.
  12. @override
  13. Widget build(BuildContext context) {
  14. return MaterialApp(
  15. title: 'Flutter Demo',
  16. theme: ThemeData(
  17. // This is the theme of your application.
  18. //
  19. // Try running your application with "flutter run". You'll see the
  20. // application has a blue toolbar. Then, without quitting the app, try
  21. // changing the primarySwatch below to Colors.green and then invoke
  22. // "hot reload" (press "r" in the console where you ran "flutter run",
  23. // or simply save your changes to "hot reload" in a Flutter IDE).
  24. // Notice that the counter didn't reset back to zero; the application
  25. // is not restarted.
  26. brightness: Brightness.light,
  27. primarySwatch: Colors.blue,
  28. ),
  29. // home: const MyHomePage(title: 'Flutter Demo Home Page'),
  30. home: LoginPage(),
  31. routes: <String, WidgetBuilder>{
  32. // 对应路由/NavigatorPushNamedPage
  33. HomePage.routeName: (BuildContext context) =>
  34. HomePage(),
  35. PatrolJobPage.routeName: (BuildContext context) =>
  36. PatrolJobPage(),
  37. DeviceManagePage.routeName: (BuildContext context) =>
  38. DeviceManagePage(),
  39. },
  40. );
  41. }
  42. }
  43. class MyHomePage extends StatefulWidget {
  44. const MyHomePage({super.key, required this.title});
  45. // This widget is the home page of your application. It is stateful, meaning
  46. // that it has a State object (defined below) that contains fields that affect
  47. // how it looks.
  48. // This class is the configuration for the state. It holds the values (in this
  49. // case the title) provided by the parent (in this case the App widget) and
  50. // used by the build method of the State. Fields in a Widget subclass are
  51. // always marked "final".
  52. final String title;
  53. @override
  54. State<MyHomePage> createState() => _MyHomePageState();
  55. }
  56. class _MyHomePageState extends State<MyHomePage> {
  57. int _counter = 0;
  58. void _incrementCounter() {
  59. setState(() {
  60. // This call to setState tells the Flutter framework that something has
  61. // changed in this State, which causes it to rerun the build method below
  62. // so that the display can reflect the updated values. If we changed
  63. // _counter without calling setState(), then the build method would not be
  64. // called again, and so nothing would appear to happen.
  65. _counter++;
  66. });
  67. }
  68. @override
  69. Widget build(BuildContext context) {
  70. // This method is rerun every time setState is called, for instance as done
  71. // by the _incrementCounter method above.
  72. //
  73. // The Flutter framework has been optimized to make rerunning build methods
  74. // fast, so that you can just rebuild anything that needs updating rather
  75. // than having to individually change instances of widgets.
  76. return Scaffold(
  77. appBar: AppBar(
  78. // Here we take the value from the MyHomePage object that was created by
  79. // the App.build method, and use it to set our appbar title.
  80. title: Text(widget.title),
  81. ),
  82. body: Center(
  83. // Center is a layout widget. It takes a single child and positions it
  84. // in the middle of the parent.
  85. child: Column(
  86. // Column is also a layout widget. It takes a list of children and
  87. // arranges them vertically. By default, it sizes itself to fit its
  88. // children horizontally, and tries to be as tall as its parent.
  89. //
  90. // Invoke "debug painting" (press "p" in the console, choose the
  91. // "Toggle Debug Paint" action from the Flutter Inspector in Android
  92. // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
  93. // to see the wireframe for each widget.
  94. //
  95. // Column has various properties to control how it sizes itself and
  96. // how it positions its children. Here we use mainAxisAlignment to
  97. // center the children vertically; the main axis here is the vertical
  98. // axis because Columns are vertical (the cross axis would be
  99. // horizontal).
  100. mainAxisAlignment: MainAxisAlignment.center,
  101. children: <Widget>[
  102. const Text(
  103. 'You have pushed the button this many times:',
  104. ),
  105. Text(
  106. '$_counter',
  107. style: Theme.of(context).textTheme.headline4,
  108. ),
  109. ],
  110. ),
  111. ),
  112. floatingActionButton: FloatingActionButton(
  113. onPressed: _incrementCounter,
  114. tooltip: 'Increment',
  115. child: const Icon(Icons.add),
  116. ), // This trailing comma makes auto-formatting nicer for build methods.
  117. );
  118. }
  119. }