catchError method

void catchError(
  1. Exception? ex, {
  2. StackTrace? stack,
  3. String? library,
  4. DiagnosticsNode? context,
  5. IterableFilter<String>? stackFilter,
  6. InformationCollector? informationCollector,
  7. bool? silent,
})
inherited

Catch and explicitly handle the error.

Implementation

void catchError(
  Exception? ex, {
  StackTrace? stack,
  String? library,
  DiagnosticsNode? context,
  IterableFilter<String>? stackFilter,
  InformationCollector? informationCollector,
  bool? silent,
}) {
  if (ex == null) {
    return;
  }

  /// If a tester is running. Don't handle the error.
  if (WidgetsBinding.instance is WidgetsFlutterBinding) {
    //
    FlutterError.onError!(FlutterErrorDetails(
      exception: ex,
      stack: stack,
      library: library ?? '',
      context: context,
      stackFilter: stackFilter,
      informationCollector: informationCollector,
      silent: silent ?? false,
    ));
  }
}