EditorImage class

Flutter EditorImage Class Documentation

The EditorImage class represents an image with multiple sources, including bytes, file, network URL, and asset path. It provides flexibility for loading images from various sources in a Flutter application.

Usage:

EditorImage image = EditorImage(
  byteArray: imageBytes,
);

Properties:

  • byteArray (optional): A byte array representing the image data.

  • file (optional): A File object representing the image file.

  • networkUrl (optional): A URL string pointing to an image on the internet.

  • assetPath (optional): A string representing the asset path of an image.

Methods:

  • hasBytes: Indicates whether the byteArray property is not null.

  • hasNetworkUrl: Indicates whether the networkUrl property is not null.

  • hasFile: Indicates whether the file property is not null.

  • hasAssetPath: Indicates whether the assetPath property is not null.

  • safeByteArray: A future that retrieves the image data as a Uint8List from the appropriate source based on the EditorImageType.

  • type: Returns the type of the image source, determined by the available properties.

Example Usage:

EditorImage image = EditorImage(
  byteArray: imageBytes,
);

if (image.hasBytes) {
  // Handle image loaded from bytes.
}

EditorImageType imageType = image.type;
switch (imageType) {
  case EditorImageType.memory:
    // Handle image loaded from memory.
    break;
  case EditorImageType.asset:
    // Handle image loaded from assets.
    break;
  case EditorImageType.file:
    // Handle image loaded from file.
    break;
  case EditorImageType.network:
    // Handle image loaded from network.
    break;
}

Please refer to the documentation of individual properties and methods for more details.

Constructors

EditorImage({Uint8List? byteArray, String? networkUrl, Map<String, String>? networkHeaders, String? assetPath, dynamic file})
Creates an instance of the EditorImage class with the specified properties.

Properties

assetPath String?
A string representing the asset path of an image.
final
byteArray Uint8List?
A byte array representing the image data.
getter/setter pair
file File?
A File object representing the image file.
final
hasAssetPath bool
Indicates whether the assetPath property is not null.
no setter
hasBytes bool
Indicates whether the byteArray property is not null.
no setter
hasFile bool
Indicates whether the file property is not null.
no setter
hashCode int
The hash code for this object.
no setteroverride
hasNetworkUrl bool
Indicates whether the networkUrl property is not null.
no setter
networkHeaders Map<String, String>?
Optional HTTP headers to use when fetching the network image.
final
networkUrl String?
A URL string pointing to an image on the internet.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type EditorImageType
Returns the type of the image source, determined by the available properties.
no setter

Methods

copyWith({Uint8List? byteArray, File? file, String? networkUrl, Map<String, String>? networkHeaders, String? assetPath}) EditorImage
Creates a copy of this EditorImage with optional new values for its fields.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
safeByteArray([BuildContext? context]) Future<Uint8List>
A future that retrieves the image data as a Uint8List from the appropriate source based on the EditorImageType.
toImageProvider() ImageProvider<Object>
Converts the current EditorImage instance to an ImageProvider.
toString() String
A string representation of this object.
inherited

Operators

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