addUIError method

dynamic addUIError(
  1. FlutterErrorDetails error
)

Implementation

addUIError(FlutterErrorDetails error) {
  if (!error.silent) {
    debugPrintStack(
      stackTrace: error.stack,
      label: error.exception.toString(),
      maxFrames: 100,
    );
  }
  final st = error.stack;
  StringBuffer sb = StringBuffer();
  sb.writeln(st.toString() + '\n\n\n\n');
  final info = error.informationCollector?.call();
  info?.forEach(
    (element) => sb.writeln(element),
  );
  final model = ErrorModel(
    isUIError: true,
    content: StringUtils.getErrorContent(error.exception.toString()),
    errorDetails: error,
    exceptionName: error.exception.runtimeType.toString(),
    startTime: DateTime.now().millisecondsSinceEpoch,
  );
  if (model.errorDetails == null) return;
  models.add(model);
  _fireOnNewErrorEvent(model.errorDetails!);
  _fireEvent();
}