TSkeleton class
A customizable skeleton loader widget that displays animated pulse/shimmer placeholders while content is loading.
TSkeleton can be used standalone to build custom loading layouts, or as
a wrapper around widgets to automatically show a placeholder when loading is true.
Named Constructors
- TSkeleton.text — For simulated lines of text.
- TSkeleton.lines — For multiple simulated paragraphs of text.
- TSkeleton.circle — For circular elements like avatars or icons.
- TSkeleton.rect — For rectangular content cards or images.
- TSkeleton.card — For full card shapes with avatar and text lines.
- TSkeleton.tile — For TTile list row placeholders.
- TSkeleton.table — For multi-row, multi-column table data skeletons.
Example Usage
// 1. Standalone shapes
TSkeleton.text(width: 150)
TSkeleton.circle(size: 48)
TSkeleton.lines(count: 3)
// 2. Complex layout
TSkeleton.card()
TSkeleton.table(rows: 5, columns: 4)
// 3. Conditional wrapper
TSkeleton(
loading: isLoading,
child: UserProfileView(user: user),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- TSkeleton
- Available extensions
Constructors
- TSkeleton({Key? key, Widget? child, bool loading = true, double? width, double? height, BorderRadius? borderRadius, BoxShape shape = BoxShape.rectangle, Color? color, Color? highlightColor, Duration duration = const Duration(milliseconds: 1500), EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin})
-
Creates a generic skeleton loader widget.
const
- TSkeleton.circle({Key? key, double size = 40.0, Color? color, Color? highlightColor, Duration duration = const Duration(milliseconds: 1500), EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, bool loading = true})
-
Creates a circular skeleton placeholder (e.g. for avatars or circular icons).
const
- TSkeleton.rect({Key? key, double? width, double? height, BorderRadius? borderRadius = const BorderRadius.all(Radius.circular(8.0)), Color? color, Color? highlightColor, Duration duration = const Duration(milliseconds: 1500), EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, bool loading = true})
-
Creates a rectangular skeleton placeholder.
const
- TSkeleton.text({Key? key, double? width, double? height = 14.0, BorderRadius? borderRadius = const BorderRadius.all(Radius.circular(4.0)), Color? color, Color? highlightColor, Duration duration = const Duration(milliseconds: 1500), EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, bool loading = true})
-
Creates a text line placeholder.
const
Properties
- borderRadius → BorderRadius?
-
Border radius of the skeleton placeholder.
final
- child → Widget?
-
The child widget to display when loading is false.
final
- color → Color?
-
Custom base color for the skeleton.
final
- duration → Duration
-
Duration of one complete pulse animation cycle.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double?
-
Height of the skeleton placeholder.
final
- highlightColor → Color?
-
Custom highlight color for the shimmer animation.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loading → bool
-
Whether the skeleton loading animation is active.
final
- margin → EdgeInsetsGeometry?
-
Optional margin around the skeleton.
final
- padding → EdgeInsetsGeometry?
-
Optional padding around the skeleton.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shape → BoxShape
-
Shape of the placeholder (rectangle or circle).
final
- width → double?
-
Width of the skeleton placeholder.
final
Methods
-
box(
{double minW = 0.0, double minH = 0.0, double maxW = double.infinity, double maxH = double.infinity}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a ConstrainedBox to apply layout constraints. -
center(
{bool when = true}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a Center widget. -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< TSkeleton> -
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
-
expanded(
{int flex = 1}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in an Expanded widget. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
padding(
[double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0]) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a Padding with flexible edge control. -
paddingSymmetric(
{double h = 0.0, double v = 0.0}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a Padding with symmetric horizontal and vertical spacing. -
size(
{double? w, double? h}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a SizedBox to apply fixed width and/or height. -
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
-
visible(
bool visible, {bool maintainState = false}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a Visibility widget. -
when(
bool condition) → Widget -
Available on Widget, provided by the WidgetX extension
Returns this widget ifconditionis true, otherwise returns SizedBox.shrink(). Usage: Text('Hello').when(isVisible)
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
card(
{Key? key, double? width, double? height, EdgeInsetsGeometry padding = const EdgeInsets.all(16.0), EdgeInsetsGeometry? margin = const EdgeInsets.only(bottom: 8.0), bool hasAvatar = true, double avatarSize = 40.0, int lines = 2, BorderRadius borderRadius = const BorderRadius.all(Radius.circular(10.0)), Color? color, Color? highlightColor, Duration duration = const Duration(milliseconds: 1500), bool loading = true}) → Widget - Creates a card skeleton with an optional avatar and text lines.
-
lines(
{Key? key, int count = 3, double spacing = 8.0, double lineHeight = 14.0, double lastLineWidthRatio = 0.65, BorderRadius borderRadius = const BorderRadius.all(Radius.circular(4.0)), Color? color, Color? highlightColor, Duration duration = const Duration(milliseconds: 1500), bool loading = true}) → Widget - Creates a multi-line paragraph placeholder.
-
table(
{Key? key, int rows = 5, int columns = 4, double rowHeight = 44.0, bool hasHeader = true, Color? color, Color? highlightColor, Duration duration = const Duration(milliseconds: 1500), bool loading = true}) → Widget - Creates a tabular data grid skeleton.
-
tile(
{Key? key, TSize size = TTileSize.h5, bool hasLeading = true, bool hasSubtitle = true, bool hasTrailing = false, Color? color, Color? highlightColor, Duration duration = const Duration(milliseconds: 1500), bool loading = true}) → Widget - Creates a tile skeleton conforming to TTile geometry.