登录流程已全部重构
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import 'package:food_health/providers/user_store.dart';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:food_health/stores/app_store.dart';
|
||||
import 'package:food_health/stores/setting_store.dart';
|
||||
import 'package:food_health/stores/user_store.dart';
|
||||
import 'package:food_health/router/routes.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
@@ -6,7 +11,9 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'config/theme/theme.dart';
|
||||
import 'providers/app_store.dart';
|
||||
import 'config/theme/themes/light_theme.dart';
|
||||
import 'l10n/app_localizations.dart';
|
||||
import 'l10n/l10n.dart';
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
@@ -14,6 +21,7 @@ void main() {
|
||||
providers: [
|
||||
ChangeNotifierProvider(create: (context) => AppStore()),
|
||||
ChangeNotifierProvider(create: (context) => UserStore()),
|
||||
ChangeNotifierProvider(create: (_) => SettingStore()),
|
||||
],
|
||||
child: MyApp(),
|
||||
),
|
||||
@@ -25,32 +33,28 @@ class MyApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//语言化
|
||||
L10n.init(context);
|
||||
|
||||
final settingStore = context.watch<SettingStore>();
|
||||
return ScreenUtilInit(
|
||||
designSize: const Size(375, 694),
|
||||
useInheritedMediaQuery: true,
|
||||
child: MaterialApp.router(
|
||||
debugShowCheckedModeBanner: false,
|
||||
routerConfig: goRouter,
|
||||
localizationsDelegates: [],
|
||||
themeMode: ThemeMode.light,
|
||||
theme: ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: scheme,
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: scheme.primary,
|
||||
foregroundColor: scheme.onPrimary,
|
||||
),
|
||||
),
|
||||
textTheme: textTheme,
|
||||
scaffoldBackgroundColor: Color(0xffFAFAFE),
|
||||
appBarTheme: AppBarTheme(
|
||||
backgroundColor: scheme.surface,
|
||||
scrolledUnderElevation: 0,
|
||||
titleTextStyle: textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
builder: EasyLoading.init(),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: [
|
||||
Locale('en'),
|
||||
Locale('zh', 'CN'),
|
||||
],
|
||||
theme: AppTheme.createTheme(LightTheme()),
|
||||
locale: settingStore.locale,
|
||||
builder: (context, child) {
|
||||
// ⚡️ 在这里就能拿到 AppLocalizations
|
||||
L10n.init(context);
|
||||
return EasyLoading.init()(context, child);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user