clone method Null safety
Creates an ImageInfo with a cloned image.
Once all outstanding references to the image are disposed, it is no longer safe to access properties of it or attempt to draw it. Clones serve to create new references to the underlying image data that can safely be disposed without knowledge of whether some other reference holder will still need access to the underlying image. Once a client disposes of its own image reference, it can no longer access the image, but other clients will be able to access their own references.
This method must be used in cases where a client holding an ImageInfo needs to share the image info object with another client and will still need to access the underlying image data at some later point, e.g. to share it again with another client.
See also:
- Image.clone, which describes how and why to clone images.
Implementation
ImageInfo clone() {
return ImageInfo(
image: image.clone(),
scale: scale,
debugLabel: debugLabel,
);
}