ByteSize Parse(String value)

Returns a ByteSize object by parsing a string value and throws an exception if argument is incorrectly formatted.

ByteSize.Parse('1024MB') == ByteSize.FromMegaBytes(1024);

Source

static ByteSize Parse(String value) {
  ParseOutput output = TryParse(value);
  if (output.isExceptionThrown == true) {
    throw FormatException('Value is not in the correct format');
  }
  return output.byteSizeObj;
}