toString method

  1. @override
String toString ()
override

Returns a string representation of this object.

Implementation

@override
String toString() {
  final StringBuffer buffer = StringBuffer();
  if ((library != null && library != '') || (context != null && context != '')) {
    if (library != null && library != '') {
      buffer.write('Error caught by $library');
      if (context != null && context != '')
        buffer.write(', ');
    } else {
      buffer.writeln('Exception ');
    }
    if (context != null && context != '')
      buffer.write('thrown $context');
    buffer.writeln('.');
  } else {
    buffer.write('An error was caught.');
  }
  buffer.writeln(exceptionAsString());
  if (informationCollector != null)
    informationCollector(buffer);
  if (stack != null) {
    Iterable<String> stackLines = stack.toString().trimRight().split('\n');
    if (stackFilter != null) {
      stackLines = stackFilter(stackLines);
    } else {
      stackLines = FlutterError.defaultStackFilter(stackLines);
    }
    buffer.writeAll(stackLines, '\n');
  }
  return buffer.toString().trimRight();
}