ImageFade class
A widget that displays a placeholder widget while a specified image loads, then cross-fades to the loaded image. Can optionally display loading progress and errors.
If image is subsequently changed, it will cross-fade to the new image once it finishes loading.
Setting image to null will cross-fade back to the placeholder.
ImageFade(
placeholder: Image.asset('assets/myPlaceholder.png'),
image: NetworkImage('https://backend.example.com/image.png'),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ImageFade
Constructors
-
ImageFade({Key? key, Widget? placeholder, ImageProvider<
Object> ? image, Curve curve = Curves.linear, Duration duration = const Duration(milliseconds: 300), Duration? syncDuration, double? width, double? height, double scale = 1, BoxFit fit = BoxFit.scaleDown, Alignment alignment = Alignment.center, ImageRepeat repeat = ImageRepeat.noRepeat, bool matchTextDirection = false, bool excludeFromSemantics = false, String? semanticLabel, ImageFadeLoadingBuilder? loadingBuilder, ImageFadeErrorBuilder? errorBuilder}) -
Creates a widget that displays a placeholder widget while a specified image loads,
then cross-fades to the loaded image.
const
Properties
- alignment → Alignment
-
How to align the image within its bounds. See Image.alignment for more information.
final
- curve → Curve
-
The curve of the fade-in animation.
final
- duration → Duration
-
The duration of the fade-in animation.
final
- errorBuilder → ImageFadeErrorBuilder?
-
A builder that specifies the widget to display if an error occurs while an image is loading.
This will be faded in over previous content, so you may want to set an opaque background on it.
final
- excludeFromSemantics → bool
-
Whether to exclude this image from semantics. See Image.excludeFromSemantics for more information.
final
- fit → BoxFit
-
How to draw the image within its bounds. Defaults to BoxFit.scaleDown. See Image.fit for more information.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double?
-
The height to display at. See Image.height for more information.
final
-
image
→ ImageProvider<
Object> ? -
The image to display. Subsequently changing the image will fade the new image over the previous one.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loadingBuilder → ImageFadeLoadingBuilder?
-
A builder that specifies the widget to display while an image is loading.
See ImageFadeLoadingBuilder for more information.
final
- matchTextDirection → bool
-
Whether to paint the image in the direction of the TextDirection. See Image.matchTextDirection for more information.
final
- placeholder → Widget?
-
Widget layered behind the loaded images. Displayed when image is null or is loading initially.
final
- repeat → ImageRepeat
-
How to paint any portions of the layout bounds not covered by the image. See Image.repeat for more information.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scale → double
-
The scale factor for drawing this image at its intended size. See RawImage.scale for more information.
final
- semanticLabel → String?
-
A Semantic description of the image. See Image.semanticLabel for more information.
final
- syncDuration → Duration?
-
An optional duration for fading in a synchronously loaded image (ex. from memory), error, or placeholder.
For example, you could set this to
Duration.zero
to immediately display images that are already loaded. If omitted, duration will be used.final - width → double?
-
The width to display at. See Image.width for more information.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< StatefulWidget> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited