main.dart 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 'global.dart';
  7. import 'routes/routes.dart';
  8. void main() async {
  9. runZonedGuarded(
  10. () async {
  11. try {
  12. WidgetsFlutterBinding.ensureInitialized();
  13. await Global.init();
  14. } catch (e) {
  15. logger.e('Global init Error', e);
  16. }
  17. runApp(const _App());
  18. },
  19. (error, stack) {
  20. // GlobalErrorHandler.handle(error, stack);
  21. },
  22. );
  23. }
  24. class _App extends StatelessWidget {
  25. const _App();
  26. @override
  27. Widget build(BuildContext context) {
  28. return GetMaterialApp(
  29. title: "家医一体机",
  30. theme: ThemeData(
  31. // primaryColor: const Color.fromRGBO(0, 178, 237, 1),
  32. // TODO:
  33. primaryColor: Colors.blue,
  34. colorScheme:
  35. ColorScheme.fromSeed(seedColor: Color(Colors.blue.value - 40)),
  36. // colorScheme: ColorScheme.fromSeed(
  37. // // seedColor: const Color.fromRGBO(44, 119, 229, 1),
  38. // // seedColor: Colors.lightBlue,
  39. // seedColor: const Color.fromRGBO(0, 178, 237, 1),
  40. // ),
  41. // colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
  42. useMaterial3: true,
  43. fontFamily: "NotoSansSC-R-fixed",
  44. fontFamilyFallback: const ["NotoSansSC-R-fixed"],
  45. ),
  46. debugShowCheckedModeBanner: false,
  47. getPages: Routes.routes,
  48. initialRoute: "splash",
  49. // initialRoute: "/patient/create",
  50. // initialRoute: "/contract/signature",
  51. // initialRoute: "/",
  52. builder: EasyLoading.init(
  53. builder: (context, widget) {
  54. const designWidth = 1280.0; // 设计尺寸宽度:1280
  55. final size = MediaQuery.of(context).size;
  56. final scale = size.width / designWidth; // 计算缩放比例
  57. return FittedBox(
  58. fit: BoxFit.fitWidth,
  59. child: SizedBox(
  60. width: designWidth,
  61. height: size.height / scale,
  62. child: Center(child: widget ?? const SizedBox()),
  63. ),
  64. );
  65. // return widget ?? const SizedBox();
  66. },
  67. ),
  68. );
  69. }
  70. }