ImageLoader class abstract
An abstract class that defines a contract for loading images.
The ImageLoader class serves as a blueprint for concrete image
loader implementations, such as loading images from network,
assets, files, or SVG formats. Any class that extends ImageLoader
must implement the loadImage method, providing the specific
logic for loading images.
Method:
Future<Widget> loadImage({...}):- Loads an image based on the provided parameters and returns a widget that displays the loaded image.
- Parameters:
path: A String representing the path or URL of the image to load.fit: A BoxFit value that determines how the image should be resized to fit its container.width: A double representing the desired width of the image.height: A double representing the desired height of the image.placeholder: An optional Widget to be displayed while the image is loading. Defaults to null if not provided.errorWidget: An optional Widget to be displayed if the image fails to load. Defaults to null if not provided.
- Returns: A Future<Widget> that resolves to a widget displaying the loaded image or the placeholder/error widget as applicable.
- Example:
Widget imageWidget = await imageLoader.loadImage( path: 'https://example.com/image.png', fit: BoxFit.cover, width: 200.0, height: 100.0, placeholder: CircularProgressIndicator(), errorWidget: Text('Failed to load image'), );
Note:
This class is intended to be subclassed, and the specific logic for loading images should be implemented in the subclasses. Each implementation can handle different image sources and error handling mechanisms as necessary.
- Implementers
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
loadImage(
{required String path, required BoxFit fit, required double width, required double height, Widget? placeholder, Widget? errorWidget}) → Future< Widget> - Loads an image based on the provided parameters and returns a widget that displays the loaded image.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited