目录
5、使用 Isolate.current.addErrorListener
2、Crashlytics (--> fabric --> Firebase)
一、flutter 崩溃收集的方式
1、通用方式
use a try/catch block
2、捕捉async异常
1)try/catch
Future main() async {
var dir = new Directory('/tmp');
try {
var dirList = dir.list();
await for (FileSystemEntity f in dirList) {
if (f is File) {
print('Found file ${f.path}');
} else if (f is Directory) {
print('Found dir ${f.path}');
}
}
} catch (e) {
print(e.toString());
}
}
2)使用 Future API
myFunc()
.then((value) {
doSomethingWith(value);
...
throw("some arbitrary error");
})
.catchError(handleError);
3)async异常 与 Future 的更多信息
3、使用 runZoned
// This creates a [Zone] that contains the Flutter application and stablishes
// an error handler that captures errors and reports them.
//
// Using