远程遥控开发中
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/infrastructure/logging/app_bloc_observer.dart';
|
||||
import 'package:maibu_satabot_v2/core/logging/i_logger_service.dart';
|
||||
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
import 'package:maibu_satabot_v2/features/auth/presentation/bloc/auth_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/presentation/bloc/devices_cubit.dart';
|
||||
@@ -12,9 +15,28 @@ import 'core/di/injection.dart';
|
||||
import 'features/auth/presentation/bloc/login_cubit.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await init();
|
||||
runApp(const MyApp());
|
||||
// 1. 使用 runZonedGuarded 捕获所有未处理的异步错误
|
||||
runZonedGuarded(
|
||||
() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
// 2. 初始化依赖注入 (这里面应包含 ILoggerService 的注册)
|
||||
await init();
|
||||
|
||||
// 3. 从 sl 中获取 logger 实例并初始化 Sentry
|
||||
final logger = sl<ILoggerService>();
|
||||
await logger.init();
|
||||
|
||||
// 4. 设置全局 Bloc 观察者,自动上报 Bloc 错误
|
||||
Bloc.observer = AppBlocObserver(logger);
|
||||
|
||||
runApp(const MyApp());
|
||||
},
|
||||
(error, stack) {
|
||||
// 5. 捕获顶级错误并上报
|
||||
sl<ILoggerService>().captureException(error, stackTrace: stack);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@@ -41,5 +63,4 @@ class MyApp extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user