ImageController class
Controller class responsible for managing image data and state. Extends ChangeNotifier to notify listeners upon state changes.
- Mixed-in types
Constructors
- ImageController.new({String key = "image", int? maxSize})
-
Constructs an ImageController with optional
key
andmaxSize
.
Properties
- bytes → Uint8List?
-
Returns the raw bytes of the current image, or null if none.
no setter
- extension → String?
-
Returns the file extension of the image, or null if none.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasImage → bool
-
Returns true if an image is loaded and its bytes are not empty.
no setter
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- hasNoImage → bool
-
Returns true if no image is loaded.
no setter
- multipartFile → MultipartFile?
-
Returns the multipart file representation of the image, or null if none.
no setter
- name → String?
-
Returns the file name of the image, or null if none.
no setter
- onDrag ↔ bool
-
Indicates whether a drag operation is currently active.
getter/setter pair
- onError ↔ bool
-
WEB
Indicates if an error occurred during image loading or processing.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → Size?
-
Returns the size of the image, or null if none.
no setter
-
stream
↔ StreamController<
bool> ? -
getter/setter pair
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
changeOnDragState(
bool state) → void -
Updates the drag state to
state
and notifies listeners if changed. -
changeOnErrorState(
bool state) → void -
Updates the error state to
state
and notifies listeners. -
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
fromAsset(
{required Map< String, String> ? headers, required String url, String? key}) → Future<void> -
Loads image data from an asset URL with optional HTTP
headers
. -
fromUint8List(
{required Uint8List bytes, required String name, String? key}) → Future< void> - Creates image data from raw bytes and a file name.
-
fromUrl(
{required Map< String, String> ? headers, required String url, String? key}) → Future<void> -
Loads image data from a URL with optional HTTP
headers
. -
getOnloadingImage(
{required String path, String? key}) → Future< void> -
Asynchronously loads an image from the specified
path
. Updates internal state and handles errors. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
pickImage(
{String? key}) → Future< void> - Opens file picker to select an image, then processes and stores it.
-
preview(
BuildContext context, {double? sigma, bool? barrierDismissible, Object? tag, Color? barrierColor, Widget? closeButton, BoxDecoration? decoration}) → void -
Displays a preview of the current image using
showImagePreview
. Allows customization of preview dialog appearance. -
removeImage(
) → void - Removes the current image and resets error state.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
startLoading(
) → void - Initiates the loading process and notifies listeners.
-
stopLoading(
) → void - Ends the loading process and notifies listeners.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateHeaders(
Map< String, String> headers) → void - Updates the HTTP headers used for image requests.
-
updateKey(
String key) → void - Updates the key identifier used for image data.
-
updateMaxSize(
int maxSize) → void - Updates the maximum allowed size for the image.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited