SkeletonLoader class

An animated shimmer skeleton loader that wraps any child widget.

While isLoading is true the widget renders a shimmer animation over grey placeholder rectangles. When isLoading becomes false the real child is revealed.

Use the static factory methods for common skeleton shapes:

// Wrap any widget
SkeletonLoader(
  isLoading: _isLoading,
  child: MyRealWidget(),
)

// Pre-built variants
SkeletonLoader.text(lines: 3)
SkeletonLoader.card(height: 140)
SkeletonLoader.avatar(size: 56)
SkeletonLoader.listItem(hasAvatar: true, textLines: 2)
Inheritance

Constructors

SkeletonLoader({required Widget child, bool isLoading = true, Key? key})
Creates a skeleton loader that wraps child.
const

Properties

child Widget
The real content revealed once isLoading is false.
final
hashCode int
The hash code for this object.
no setterinherited
isLoading bool
Whether the skeleton placeholder is currently shown.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<SkeletonLoader>
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, int wrapWidth = 65}) 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

Static Methods

avatar({Key? key, double size = 48}) Widget
A circular avatar skeleton.
card({Key? key, double height = 120}) Widget
A rectangular card skeleton.
listItem({Key? key, bool hasAvatar = true, int textLines = 2}) Widget
A list-item skeleton with an optional leading avatar and text lines.
text({Key? key, int lines = 3, double? width}) Widget
A multi-line text skeleton.