main.dart 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/services.dart';
  3. import 'package:flutter_localizations/flutter_localizations.dart';
  4. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  5. import 'package:lszlgl/router/my_navigator.dart';
  6. import 'package:lszlgl/router/my_router.dart';
  7. void main() {
  8. WidgetsFlutterBinding.ensureInitialized();
  9. SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light.copyWith(statusBarColor: Colors.transparent));
  10. SystemChrome.setPreferredOrientations([
  11. DeviceOrientation.portraitUp,
  12. DeviceOrientation.portraitDown,
  13. ]);
  14. runApp(const MyApp());
  15. }
  16. class MyApp extends StatelessWidget {
  17. const MyApp({super.key});
  18. @override
  19. Widget build(BuildContext context) {
  20. return MaterialApp(
  21. title: '粮食质量管理',
  22. theme: ThemeData(
  23. colorScheme: ColorScheme.fromSeed(
  24. seedColor: Colors.blue,
  25. ),
  26. scaffoldBackgroundColor: const Color(0xFFF5F5F5),
  27. // navigationBarTheme: const NavigationBarThemeData(height: 56),
  28. appBarTheme: const AppBarTheme(
  29. centerTitle: true,
  30. foregroundColor: Colors.white,
  31. backgroundColor: Colors.transparent,
  32. systemOverlayStyle: SystemUiOverlayStyle.light,
  33. ),
  34. useMaterial3: true,
  35. ),
  36. navigatorObservers: [FlutterSmartDialog.observer],
  37. builder: FlutterSmartDialog.init(),
  38. localizationsDelegates: const [
  39. GlobalMaterialLocalizations.delegate,
  40. GlobalCupertinoLocalizations.delegate,
  41. GlobalWidgetsLocalizations.delegate,
  42. ],
  43. supportedLocales: const [Locale('zh')],
  44. onGenerateRoute: rOnGenerateRoute,
  45. navigatorKey: Nav.navigatorKey,
  46. );
  47. }
  48. }
  49. class MyHomePage extends StatefulWidget {
  50. const MyHomePage({super.key, required this.title});
  51. final String title;
  52. @override
  53. State<MyHomePage> createState() => _MyHomePageState();
  54. }
  55. class _MyHomePageState extends State<MyHomePage> {
  56. int _counter = 0;
  57. void _incrementCounter() {
  58. setState(() {
  59. _counter++;
  60. });
  61. }
  62. @override
  63. Widget build(BuildContext context) {
  64. return Scaffold(
  65. appBar: AppBar(
  66. backgroundColor: Theme.of(context).colorScheme.inversePrimary,
  67. title: Text(widget.title),
  68. ),
  69. body: Center(
  70. child: Column(
  71. mainAxisAlignment: MainAxisAlignment.center,
  72. children: <Widget>[
  73. const Text(
  74. 'You have pushed the button this many times:',
  75. ),
  76. Text(
  77. '$_counter',
  78. style: Theme.of(context).textTheme.headlineMedium,
  79. ),
  80. ],
  81. ),
  82. ),
  83. floatingActionButton: FloatingActionButton(
  84. onPressed: _incrementCounter,
  85. tooltip: 'Increment',
  86. child: const Icon(Icons.add),
  87. ),
  88. );
  89. }
  90. }