Blob class
An immutable sequence of bytes, the value of a bytes field in a document.
Two blobs are equal when their bytes and their subtype are equal, and blobs are ordered by subtype and then byte by byte.
Store a Blob as a field value; a snapshot returns it for a bytes
field, also through DocumentSnapshot.getBlob.
final Blob icon = Blob(Uint8List.fromList(<int>[0x89, 0x50, 0x4e, 0x47]));
await firestore.doc('files/icon').set(<String, Object?>{'data': icon});
final DocumentSnapshot<Map<String, Object?>> snapshot =
await firestore.doc('files/icon').get();
final Uint8List? bytes = (snapshot.get('data') as Blob?)?.bytes;
The blob counts toward the size limit of its document.
This is Bytes in the JS SDK and Blob in the Android SDK.
- Implemented types
Constructors
- Blob(Uint8List bytes)
-
Creates a blob holding a copy of
bytes; later changes tobytesdo not affect the blob. Its subtype is 0. - Blob.bsonBinary(int subtype, Uint8List bytes)
-
Creates BSON binary data, a blob with a
subtype. - Blob.fromBase64String(String base64String)
-
Creates a blob from a base64-encoded string, the inverse of toBase64.
factory
-
Blob.fromJson(Map<
String, Object?> json) -
Builds a blob from a JSON map created by toJson.
factory
Properties
- bytes → Uint8List
-
A copy of the bytes of this blob (a blob is immutable, as upstream).
Each call copies, so keep the result if you read it more than once.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- subtype → int
-
The subtype of BSON binary data, 0 for a regular blob.
final
Methods
-
compareTo(
Blob other) → int -
Compares this object to another object.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toBase64(
) → String - The bytes of this blob, base64-encoded.
-
toJson(
) → Map< String, Object> -
A JSON-serializable representation of this blob, in the same shape as the
JS SDK's
Bytes.toJSON(). Read it back with Blob.fromJson. -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override