Chain.parse constructor Null safety

Chain.parse(
  1. String chain
)

Parses a string representation of a stack chain.

If chain is the output of a call to Chain.toString, it will be parsed as a full stack chain. Otherwise, it will be parsed as in Trace.parse and returned as a single-trace chain.

Implementation

factory Chain.parse(String chain) {
  if (chain.isEmpty) return Chain([]);
  if (chain.contains(vmChainGap)) {
    return Chain(chain
        .split(vmChainGap)
        .where((line) => line.isNotEmpty)
        .map(Trace.parseVM));
  }
  if (!chain.contains(chainGap)) return Chain([Trace.parse(chain)]);

  return Chain(chain.split(chainGap).map(Trace.parseFriendly));
}