Blob class abstract Document

A Blob contains arbitrary binary data, tagged with a MIME type.

Blobs can be arbitrarily large, and their data is loaded only on demand (when the content or contentStream properties are accessed), not when the Document is loaded. The document’s raw JSON form only contains the Blob’s metadata (type, length and a digest of the data) in a small object. The data itself is stored externally to the document, keyed by the digest.

The digest of a Blob is only available after it has been saved to a Database. If a Blob is part of a Document, it is automatically saved when that document is being saved. Alternatively, a Blob can also be saved explicitly, with Database.saveBlob.


Blob.fromData(String contentType, Uint8List data)
Creates a Blob with the given in-memory data.
Blob.fromStream(String contentType, Stream<Uint8List> stream)
Creates a Blob from a stream of chunks of data.


contentType String?
The type of content this Blob represents.
no setter
digest String?
The cryptographic digest of this Blob’s content, which uniquely identifies it.
no setter
hashCode int
The hash code for this object.
no setterinherited
length int?
The binary length of this Blob.
no setter
properties Map<String, Object?>
The metadata representation of this Blob.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited


content() Future<Uint8List>
Gets the contents of this Blob as a block of memory.
contentStream() Stream<Uint8List>
A stream of the content of this Blob.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
toJson() String
Returns this blob's JSON representation.
toString() String
A string representation of this object.


operator ==(Object other) bool
The equality operator.

Static Methods

isBlob(Map<String, Object?> properties) bool
Whether a plain Dart Map contains valid Blob metadata.