美文网首页
flutter 1.3捕抓异常

flutter 1.3捕抓异常

作者: 你飞跃俊杰 | 来源:发表于2019-08-23 15:09 被阅读0次

    void collectLog(String line){
    ... //收集日志
    }
    void reportErrorAndLog(FlutterErrorDetails details){
    ... //上报错误和日志逻辑
    }

    FlutterErrorDetails makeDetails(Object obj, StackTrace stack){
    ...// 构建错误信息
    }

    void main() {
    FlutterError.onError = (FlutterErrorDetails details) {
    reportErrorAndLog(details);
    };
    runZoned(
    () => runApp(MyApp()),
    zoneSpecification: ZoneSpecification(
    print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
    collectLog(line); // 收集日志
    },
    ),
    onError: (Object obj, StackTrace stack) {
    var details = makeDetails(obj, stack);
    reportErrorAndLog(details);
    },
    );
    }

    相关文章

      网友评论

          本文标题:flutter 1.3捕抓异常

          本文链接:https://www.haomeiwen.com/subject/vbhtectx.html