main.dart 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import 'package:eitc_erm_app/select_clinic.dart';
  2. import 'package:eitc_erm_app/utils/Constants.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_localizations/flutter_localizations.dart';
  5. import 'bottom_navigation.dart';
  6. import 'doctor_talk_list.dart';
  7. import 'login.dart';
  8. void main() {
  9. runApp(const Main());
  10. }
  11. class Main extends StatelessWidget {
  12. const Main({super.key});
  13. @override
  14. Widget build(BuildContext context) {
  15. return MaterialApp(
  16. localizationsDelegates: const [
  17. GlobalMaterialLocalizations.delegate,
  18. GlobalWidgetsLocalizations.delegate,
  19. GlobalCupertinoLocalizations.delegate, //多加这行代码
  20. ],
  21. supportedLocales: const [
  22. Locale('en', 'US'), // 美国英语
  23. Locale('zh', 'CN'), // 中文简体
  24. //其它Locales
  25. ],
  26. theme: ThemeData(
  27. primarySwatch: Colors.blue,
  28. ),
  29. home: SplashScreen(),
  30. routes: {
  31. '/login': (context) => Login(),
  32. '/home': (context) => BottomNavigationWidget(),
  33. '/doctor': (context) => DoctorTalkList(),
  34. '/selectClinic': (context) => SelectClinic(""),
  35. },
  36. );
  37. }
  38. }
  39. class SplashScreen extends StatefulWidget {
  40. @override
  41. _SplashScreenState createState() => _SplashScreenState();
  42. }
  43. class _SplashScreenState extends State<SplashScreen> {
  44. @override
  45. void initState() {
  46. super.initState();
  47. // 在这里可以进行一些初始化操作,如加载数据等
  48. // 通过Future.delayed方法模拟加载时间
  49. Future.delayed(Duration(seconds: 3), () async {
  50. /*if(!(await Utils.readData("token")).isEmpty) {
  51. Global.token = await Utils.readData("token");
  52. Navigator.pushReplacementNamed(context, '/home');
  53. } else if(!(await Utils.readData("doctorToken")).isEmpty) {
  54. Global.token = await Utils.readData("doctorToken");
  55. Navigator.pushReplacementNamed(context, '/doctor');
  56. } else
  57. Navigator.pushReplacementNamed(context, '/login');*/
  58. Navigator.pushReplacementNamed(context, '/selectClinic');
  59. });
  60. }
  61. @override
  62. Widget build(BuildContext context) {
  63. return Scaffold(
  64. body: Center(
  65. child: Column(
  66. mainAxisAlignment: MainAxisAlignment.center,
  67. children: [
  68. FlutterLogo(
  69. size: 100,
  70. ),
  71. SizedBox(height: 16),
  72. Text(
  73. '智慧口腔诊所',
  74. style: TextStyle(
  75. fontSize: 24,
  76. fontWeight: FontWeight.bold,
  77. ),
  78. ),
  79. SizedBox(height: 16),
  80. CircularProgressIndicator(),
  81. ],
  82. ),
  83. ),
  84. );
  85. }
  86. }