main.dart 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import 'dart:async';
  2. import 'package:flutter/material.dart';
  3. import 'package:fis_common/logger/logger.dart';
  4. import 'package:flutter_easyloading/flutter_easyloading.dart';
  5. import 'package:get/get.dart';
  6. import 'package:vitalapp/components/floating_window/index.dart';
  7. import 'package:vitalapp/store/store.dart';
  8. import 'global.dart';
  9. import 'routes/routes.dart';
  10. void main() async {
  11. runZonedGuarded(
  12. () async {
  13. try {
  14. WidgetsFlutterBinding.ensureInitialized();
  15. await Global.init();
  16. } catch (e) {
  17. logger.e('Global init Error', e);
  18. }
  19. runApp(const _App());
  20. },
  21. (error, stack) {
  22. logger.e('runZonedGuarded Error', error);
  23. // GlobalErrorHandler.handle(error, stack);
  24. },
  25. );
  26. }
  27. class _App extends StatelessWidget {
  28. const _App();
  29. @override
  30. Widget build(BuildContext context) {
  31. return GetMaterialApp(
  32. title: "杏聆荟健康平台",
  33. theme: ThemeData(
  34. // primaryColor: const Color.fromRGBO(0, 178, 237, 1),
  35. // TODO:
  36. primaryColor: Colors.blue,
  37. colorScheme:
  38. ColorScheme.fromSeed(seedColor: Color(Colors.blue.value - 40)),
  39. // colorScheme: ColorScheme.fromSeed(
  40. // // seedColor: const Color.fromRGBO(44, 119, 229, 1),
  41. // // seedColor: Colors.lightBlue,
  42. // seedColor: const Color.fromRGBO(0, 178, 237, 1),
  43. // ),
  44. // colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
  45. useMaterial3: true,
  46. fontFamily: "NotoSansSC-R-fixed",
  47. fontFamilyFallback: const ["NotoSansSC-R-fixed"],
  48. ),
  49. debugShowCheckedModeBanner: false,
  50. getPages: Routes.routes,
  51. initialRoute: "splash",
  52. // initialRoute: "/patient/create",
  53. // initialRoute: "/contract/signature",
  54. // initialRoute: "/",
  55. builder: EasyLoading.init(
  56. builder: (context, widget) {
  57. const designWidth = 1280.0; // 设计尺寸宽度:1280
  58. final size = MediaQuery.of(context).size;
  59. final scale = size.width / designWidth; // 计算缩放比例
  60. return FittedBox(
  61. fit: BoxFit.fitWidth,
  62. child: SizedBox(
  63. width: designWidth,
  64. height: size.height / scale,
  65. child: Center(child: widget ?? const SizedBox()),
  66. ),
  67. );
  68. },
  69. ),
  70. );
  71. }
  72. Widget _buildPatient() {
  73. if (Store.user.currentSelectPatientInfo?.patientName?.isNotEmpty ?? false) {
  74. return Text(
  75. Store.user.currentSelectPatientInfo?.patientName ?? '',
  76. style: const TextStyle(
  77. color: Colors.white,
  78. fontSize: 20,
  79. ),
  80. overflow: TextOverflow.ellipsis,
  81. );
  82. } else {
  83. return const Icon(
  84. Icons.add,
  85. size: 40,
  86. color: Colors.white,
  87. );
  88. }
  89. }
  90. }