fromStackString method Null safety

List<StackFrame> fromStackString(
  1. String stack
)

Parses a list of StackFrames from the StackTrace.toString method.

Implementation

static List<StackFrame> fromStackString(String stack) {
  assert(stack != null);
  return stack
      .trim()
      .split('\n')
      .where((String line) => line.isNotEmpty)
      .map(fromStackTraceLine)
      // On the Web in non-debug builds the stack trace includes the exception
      // message that precedes the stack trace itself. fromStackTraceLine will
      // return null in that case. We will skip it here.
      .whereType<StackFrame>()
      .toList();
}