我试图捕获Flutter应用程序中所有未处理的异常。这是我的main.dart文件:
void main() async {
FlutterError.onError = (FlutterErrorDetails details) {
print("FlutterError.onError");
};
try {
runZoned<Future<void>>(
() async {
runApp(App());
},
onError: (dynamic error, StackTrace stackTrace) {
print("runZoned.onError");
},
);
} catch (ex) {
print("main.catch");
}
}
然而,这些方法都无法解决问题,当我在iOS模拟器上运行我的应用程序时,它输出以下内容:
[VERBOSE-2:ui_dart_state.cc(166)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 61, address = localhost, port = 57562
我该如何捕获这个异常?