Image class
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:
- Image, the class in the widgets library.
- ImageDescriptor, which allows reading information about the image and creating a codec to decode it.
- instantiateImageCodec, a utility method that wraps ImageDescriptor.
Properties
- colorSpace → ColorSpace
-
The color space that is used by the Image's colors.
no setter
- debugDisposed → bool
-
Whether this reference to the underlying image is disposed.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- 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.
no setterinherited
- 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 orother
is disposed. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent 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
Static Properties
- onCreate ↔ ImageEventCallback?
-
A callback that is invoked to report an image creation.
getter/setter pair
- onDispose ↔ ImageEventCallback?
-
A callback that is invoked to report the image disposal.
getter/setter pair