Image class final

A PNG or JPEG image to put wherever a request takes text: in state, in a question's instructions, or in its criteria. The request uploads it once as a file part and the model sees the image where its reference is.

Experimental: the API only reads images when the request carries the TypeSafe-Danger-Zone-Images: true header (DangerZone.images), and TypeSafe may change the format, the answers and the limits.

The bytes are not copied, so don't change them after building the image. The API checks the size and pixel limits; this class only checks the format, so a limit TypeSafe changes is never enforced here.

Implemented types
Annotations
  • @experimental
  • @immutable

Constructors

Image(Uint8List bytes, {String? reference})

Properties

bytes → Uint8List
The file's bytes, sent as they are.
final
format → ImageFormat
The file format, detected from the bytes.
final
hashCode → int
The hash code for this object.
no setterinherited
reference → String
The text that stands for this image in the request. References are matched as plain text, so a custom one must not occur in your text.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → String
Returns reference, and records this image as one the request being encoded must upload.
override
toString() → String
Not the reference: interpolating an image into a string would lose it. Use TextWithImages to put an image inside a sentence.
override

Operators

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

Static Methods

fromFile(String path, {String? reference}) → Future<Image>
Reads the PNG or JPEG file at path.