这是CaiYouHui前端,一个关于flutter的安卓app,前端使用flutter实现

main.dart 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import 'package:flutter/material.dart';
  2. import 'package:provider/provider.dart';
  3. import 'core/constants/route_constants.dart';
  4. import 'presentation/providers/auth_provider.dart';
  5. import 'presentation/providers/user_provider.dart';
  6. import 'presentation/navigation/app_router.dart';
  7. import 'injection_container.dart' as di;
  8. void main() async {
  9. WidgetsFlutterBinding.ensureInitialized();
  10. await di.init(); // 初始化DI容器
  11. runApp(const MyApp());
  12. }
  13. class MyApp extends StatelessWidget {
  14. const MyApp({super.key});
  15. // This widget is the root of your application.
  16. @override
  17. Widget build(BuildContext context) {
  18. return MultiProvider(
  19. providers: [
  20. ChangeNotifierProvider(create: (_) => di.sl<AuthProvider>()),
  21. ChangeNotifierProvider(create: (_) => di.sl<UserProvider>()),
  22. ],
  23. child: MaterialApp(
  24. title: '中了么',
  25. theme: ThemeData(
  26. primarySwatch: Colors.blue,
  27. // fontFamily: 'Roboto',
  28. appBarTheme: const AppBarTheme(
  29. backgroundColor: Colors.white,
  30. foregroundColor: Colors.black,
  31. elevation: 0,
  32. centerTitle: true,
  33. ),
  34. scaffoldBackgroundColor: Colors.white,
  35. bottomNavigationBarTheme: const BottomNavigationBarThemeData(
  36. backgroundColor: Colors.white,
  37. selectedItemColor: Colors.blue,
  38. unselectedItemColor: Colors.grey,
  39. showUnselectedLabels: true,
  40. ),
  41. ),
  42. debugShowCheckedModeBanner: false,
  43. initialRoute: RouteConstants.splash,
  44. onGenerateRoute: AppRouter.onGenerateRoute,
  45. ),
  46. );
  47. }
  48. }