SvgImageLoader class
A concrete implementation of ImageLoader that loads SVG images from assets.
The SvgImageLoader class extends the ImageLoader abstract class
and provides functionality to load SVG images from the application's asset bundle.
Method:
Future<Widget> loadImage({...}):- Loads an SVG image from the specified asset path.
- Parameters:
path: A String representing the asset path of the SVG 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 SVG image, or a placeholder/error widget as applicable.
- Example:
Widget svgWidget = await svgImageLoader.loadImage( path: 'assets/images/icon.svg', fit: BoxFit.cover, width: 100.0, height: 100.0, placeholder: CircularProgressIndicator(), errorWidget: Text('Failed to load SVG'), );
Error Handling:
If the SVG image cannot be loaded from the specified asset path,
the method will return the specified errorWidget or an ErrorPlaceholder
widget if no error widget is provided.
- Inheritance
-
- Object
- ImageLoader
- SvgImageLoader
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 SVG image from the specified asset path.
override
-
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