toJson method

Map<String, Object> toJson()

A JSON-serializable representation of this blob, in the same shape as the JS SDK's Bytes.toJSON(). Read it back with Blob.fromJson.

Implementation

Map<String, Object> toJson() {
  return <String, Object>{
    'type': jsonType,
    'bytes': toBase64(),
    // The backend rejects a subtype of 0, so it is left out like the JS SDK
    // does.
    if (subtype != 0) 'subtype': subtype,
  };
}