StackTraceElement.fromString constructor

StackTraceElement.fromString(
  1. String line
)

Implementation

factory StackTraceElement.fromString(String line) {
  final regex = RegExp(r'#\d+\s+(\w+)\.(\w+)\s+\((.+):(\d+):(\d+)\)');
  final match = regex.firstMatch(line);

  if (match != null) {
    return StackTraceElement(
      match.group(1)!,
      match.group(2)!,
      match.group(3)!,
      int.parse(match.group(4)!),
    );
  }

  return StackTraceElement('<unknown>', '<unknown>', '<unknown>', 0);
}