main.dart 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import 'dart:io';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:hengyi/config/config.dart';
  5. import 'package:hengyi/home/home.dart';
  6. import 'package:hengyi/utils/dio_util.dart';
  7. void main() {
  8. runApp(MyApp());
  9. }
  10. class MyApp extends StatelessWidget {
  11. const MyApp({super.key});
  12. @override
  13. Widget build(BuildContext context) {
  14. return ScreenUtilInit(
  15. designSize: const Size(1920, 1080),
  16. builder: (context, child) {
  17. return MaterialApp(
  18. title: "夫为服务",
  19. home: FutureBuilder(
  20. future: NetworkUtil().getWebConfig(),
  21. builder: (context, snapshot) {
  22. if (snapshot.connectionState == ConnectionState.done) {
  23. if (snapshot.hasData) {
  24. AppConfig.configPhone = snapshot.data?.configPhone ?? "";
  25. AppConfig.configAddress =
  26. snapshot.data?.configAddress ?? "";
  27. AppConfig.configWechatUrl =
  28. snapshot.data?.configWechatUrl ?? "";
  29. AppConfig.configWebName =
  30. snapshot.data?.configWebName ?? "";
  31. AppConfig.configWebBeian =
  32. snapshot.data?.configWebBeian ?? "";
  33. AppConfig.configWebZhuti =
  34. snapshot.data?.configWebZhuti ?? "";
  35. AppConfig.configContent =
  36. snapshot.data?.configContent ?? "";
  37. return HomePage();
  38. } else {
  39. return Text("Error:${snapshot.error}");
  40. }
  41. } else {
  42. return Container(
  43. alignment: Alignment.center,
  44. child: const CircularProgressIndicator(),
  45. );
  46. }
  47. },
  48. ),
  49. );
  50. });
  51. }
  52. }