AssetId.parse constructor

AssetId.parse(
  1. String id
)

Parses an AssetId string of the form $package|$path.

If id does not match that form, a FormatException is thrown.

See AssetId.new for restrictions on path and how it will be normalized.

Implementation

factory AssetId.parse(String id) {
  final parts = id.split('|');
  if (parts.length != 2) {
    throw FormatException('Could not parse "$id".');
  }

  return AssetId(parts[0], parts[1]);
}