Image class Null safety

Opaque handle to raw decoded image data (pixels).

To obtain an Image object, use the ImageDescriptor API.

To draw an Image, use one of the methods on the Canvas class, such as Canvas.drawImage.

A class or method that receives an image object must call dispose on the handle when it is no longer needed. To create a shareable reference to the underlying image, call clone. The method or object that receives the new instance will then be responsible for disposing it, and the underlying image itself will be disposed when all outstanding handles are disposed.

If dart:ui passes an Image object and the recipient wishes to share that handle with other callers, clone must be called before dispose. A handle that has been disposed cannot create new handles anymore.

See also:

Properties

debugDisposed bool
Whether this reference to the underlying image is disposed.
read-only
hashCode int
The hash code for this object.
read-onlyinherited
height int
The number of image pixels along the image's vertical axis.
final
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
width int
The number of image pixels along the image's horizontal axis.
final

Methods

clone() Image
Creates a disposable handle to this image.
debugGetOpenHandleStackTraces() List<StackTrace>?
If asserts are enabled, returns the StackTraces of each open handle from clone, in creation order.
dispose() → void
Release this handle's claim on the underlying Image. This handle is no longer usable after this method is called.
isCloneOf(Image other) bool
Returns true if other is a clone of this and thus shares the same underlying image memory, even if this or other is disposed.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toByteData({ImageByteFormat format = ImageByteFormat.rawRgba}) Future<ByteData?>
Converts the Image object into a byte array.
toString() String
A string representation of this object.
override

Operators

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