InitReportException<T> method

Future<void> InitReportException<T>(
  1. T callback(), {
  2. int type = 1,
  3. bool isSync = false,
})
override

Implementation

Future<void> InitReportException<T> (T callback(),{int type = 1,bool isSync = false}) async {
  FlutterError.onError = (details) {
    if (details.stack != null) {
      String exception = details.exceptionAsString();
      String stack = details.stack.toString();

      ReportException("flutter error", exception, stack, 1, false);
    } else {
      FlutterError.presentError(details);
    }
  };

  runZonedGuarded<Future<Null>>(() async {
    callback();
  }, (error, stackTrace) {
    ReportException(
        "flutter error", error.toString(), stackTrace.toString(), type,
        isSync);
  });
}