main.dart 2.7 KB

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