refactor: 清理未使用的倒计时状态变量并优化初始化日志
fix: 移除mini_card_page中未使用的_isCountdownActive变量 style: 在app_service和main中添加详细的初始化日志 chore: 删除fluttertoast_ohos相关的废弃文件
This commit is contained in:
@@ -24,7 +24,9 @@ import 'package:mom_kitchen/src/utils/app_logger.dart';
|
||||
|
||||
void main() async {
|
||||
// 确保 Flutter 引擎初始化
|
||||
debugPrint('🚀 开始初始化 Flutter 引擎...');
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
debugPrint('✅ Flutter 引擎初始化完成');
|
||||
|
||||
FlutterError.onError = (FlutterErrorDetails details) {
|
||||
FlutterError.presentError(details);
|
||||
@@ -34,22 +36,33 @@ void main() async {
|
||||
};
|
||||
|
||||
// 初始化所有服务
|
||||
await AppService.instance.init();
|
||||
debugPrint('📱 开始初始化应用服务...');
|
||||
try {
|
||||
await AppService.instance.init();
|
||||
debugPrint('✅ 应用服务初始化完成');
|
||||
} catch (e) {
|
||||
debugPrint('❌ 应用服务初始化失败: $e');
|
||||
rethrow;
|
||||
}
|
||||
|
||||
// 📋 页面注册入口 - 在此处调用注册所有页面
|
||||
if (kDebugMode) {
|
||||
AppLogger.i('📋 开始注册页面...');
|
||||
debugPrint('📋 开始注册页面...');
|
||||
AppRoutes.registerAllPages();
|
||||
AppLogger.i('✅ 页面注册完成,共注册 ${PageRegistry.pageCount} 个页面');
|
||||
debugPrint('✅ 页面注册完成,共注册 ${PageRegistry.pageCount} 个页面');
|
||||
|
||||
final config = PageRegistry.exportConfig();
|
||||
AppLogger.d('📊 页面配置: $config');
|
||||
debugPrint('📊 页面配置: $config');
|
||||
}
|
||||
|
||||
debugPrint('🔄 解锁屏幕方向...');
|
||||
await OrientationService().unlockOrientation();
|
||||
debugPrint('✅ 屏幕方向解锁完成');
|
||||
|
||||
// 运行应用
|
||||
debugPrint('🎯 启动应用...');
|
||||
runApp(const MyApp());
|
||||
debugPrint('✅ 应用启动完成');
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
|
||||
@@ -73,7 +73,6 @@ class _MiniCardPageState extends State<MiniCardPage> {
|
||||
|
||||
Timer? _countdownTimer;
|
||||
double _countdownProgress = 1.0;
|
||||
final bool _isCountdownActive = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -326,7 +325,7 @@ class _MiniCardPageState extends State<MiniCardPage> {
|
||||
_countdownTimer = Timer.periodic(const Duration(milliseconds: stepMs), (
|
||||
timer,
|
||||
) {
|
||||
if (!mounted || !_isCountdownActive) {
|
||||
if (!mounted) {
|
||||
timer.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,18 +49,44 @@ class AppService {
|
||||
}
|
||||
|
||||
Future<void> init() async {
|
||||
debugPrint('📦 初始化存储服务...');
|
||||
await storage.init();
|
||||
debugPrint('✅ 存储服务初始化完成');
|
||||
|
||||
debugPrint('🗄️ 初始化 Hive 服务...');
|
||||
await hive.init();
|
||||
debugPrint('✅ Hive 服务初始化完成');
|
||||
|
||||
debugPrint('🎨 初始化主题服务...');
|
||||
await theme.init();
|
||||
debugPrint('✅ 主题服务初始化完成');
|
||||
|
||||
debugPrint('📱 初始化应用信息服务...');
|
||||
await appInfo.init();
|
||||
debugPrint('✅ 应用信息服务初始化完成');
|
||||
|
||||
if (!kIsWeb) {
|
||||
debugPrint('🔒 初始化权限服务...');
|
||||
await permission!.init();
|
||||
debugPrint('✅ 权限服务初始化完成');
|
||||
}
|
||||
|
||||
debugPrint('✨ 初始化动画服务...');
|
||||
await animation.init();
|
||||
debugPrint('✅ 动画服务初始化完成');
|
||||
|
||||
debugPrint('📝 初始化日志服务...');
|
||||
await logger.init();
|
||||
debugPrint('✅ 日志服务初始化完成');
|
||||
|
||||
debugPrint('📐 初始化屏幕工具服务...');
|
||||
await screenUtil.init();
|
||||
debugPrint('✅ 屏幕工具服务初始化完成');
|
||||
|
||||
if (!kIsWeb) {
|
||||
debugPrint('🌐 初始化网络连接服务...');
|
||||
Get.put(connectivity!);
|
||||
debugPrint('✅ 网络连接服务初始化完成');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user