AutoShimmer class

A widget that automatically applies a shimmer effect to its child widget.

The shimmer effect creates a smooth, animated gradient that moves across the child, commonly used to indicate loading states or placeholder content. The effect can be controlled through various parameters including duration, colors, and visibility.

Features:

  • Automatic animation: Starts and stops based on the showShimmer parameter
  • Customizable colors: Configure base and highlight colors for the shimmer effect
  • Adjustable duration: Control the speed of the shimmer animation
  • Border radius preservation: Attempts to maintain the child's border radius
  • Performance optimized: Uses efficient animation controllers and shader masks

Usage:

AutoShimmer(
  showShimmer: isLoading,
  child: Container(
    height: 100,
    decoration: BoxDecoration(
      color: Colors.white,
      borderRadius: BorderRadius.circular(8),
    ),
  ),
)

Parameters:

  • child: The widget to apply the shimmer effect to
  • duration: The duration of one complete shimmer cycle (default: 2 seconds)
  • baseColor: The base color of the shimmer effect (default: light gray)
  • highlightColor: The highlight color that creates the shimmer effect (default: lighter gray)
  • showShimmer: Whether to show the shimmer effect (default: true)
Inheritance

Constructors

AutoShimmer({Key? key, required Widget child, Duration duration = const Duration(seconds: 2), Color baseColor = const Color(0xFFE0E0E0), Color highlightColor = const Color(0xFFF5F5F5), bool showShimmer = true})
Creates an AutoShimmer widget.
const

Properties

baseColor Color
The base color of the shimmer effect.
final
child Widget
The widget to apply the shimmer effect to.
final
duration Duration
The duration of one complete shimmer cycle.
final
hashCode int
The hash code for this object.
no setterinherited
highlightColor Color
The highlight color of the shimmer effect.
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
showShimmer bool
Whether to show the shimmer effect.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<AutoShimmer>
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