111
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ui';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
@@ -25,34 +25,32 @@ void main() async {
|
||||
// 确保 Flutter 绑定初始化
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
// 全局错误处理
|
||||
// 全局错误处理 - Flutter 框架错误
|
||||
FlutterError.onError = (FlutterErrorDetails details) {
|
||||
FlutterError.presentError(details);
|
||||
debugPrint('Flutter Error: ${details.exception}');
|
||||
debugPrint('Stack trace: ${details.stack}');
|
||||
};
|
||||
|
||||
// 捕获异步错误
|
||||
runZonedGuarded<Future<void>>(
|
||||
() async {
|
||||
Provider.debugCheckInvalidValueType = null;
|
||||
// 全局错误处理 - 异步未捕获错误
|
||||
PlatformDispatcher.instance.onError = (error, stack) {
|
||||
debugPrint('Uncaught error: $error');
|
||||
debugPrint('Stack: $stack');
|
||||
return true;
|
||||
};
|
||||
|
||||
try {
|
||||
await SharedPreferences.getInstance();
|
||||
await LocalStorage.init();
|
||||
debugPrint('App initialized successfully');
|
||||
} catch (e, stack) {
|
||||
debugPrint('Initialization error: $e');
|
||||
debugPrint('Stack: $stack');
|
||||
}
|
||||
Provider.debugCheckInvalidValueType = null;
|
||||
|
||||
runApp(const MyApp());
|
||||
},
|
||||
(error, stack) {
|
||||
debugPrint('Uncaught error: $error');
|
||||
debugPrint('Stack: $stack');
|
||||
},
|
||||
);
|
||||
try {
|
||||
await SharedPreferences.getInstance();
|
||||
await LocalStorage.init();
|
||||
debugPrint('App initialized successfully');
|
||||
} catch (e, stack) {
|
||||
debugPrint('Initialization error: $e');
|
||||
debugPrint('Stack: $stack');
|
||||
}
|
||||
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
|
||||
Reference in New Issue
Block a user