SkeletonLoader constructor

SkeletonLoader({
  1. Key? key,
  2. required Widget child,
  3. required bool isLoading,
  4. Color? baseColor,
  5. Color? highlightColor,
  6. Duration? shimmerDuration,
  7. Duration? transitionDuration,
})

SkeletonLoader wraps any Flutter widget and automatically creates a skeleton version of it when isLoading is true. When the data is ready, it smoothly transitions to show the actual content.

The skeleton version mimics the structure of the original widget with a shimmer animation to indicate the loading state.

Example usage:

SkeletonLoader(
  isLoading: _isLoading, // Set to true while loading data
  child: Text('Content loaded successfully!'),
)

You can customize the appearance of the skeleton by adjusting the baseColor, highlightColor, and animation speed with shimmerDuration.

Implementation

factory SkeletonLoader({
  Key? key,
  required Widget child,
  required bool isLoading,
  Color? baseColor,
  Color? highlightColor,
  Duration? shimmerDuration,
  Duration? transitionDuration,
}) {
  final config = SkeletonConfig.instance;

  return SkeletonLoader._internal(
    key: key,
    isLoading: isLoading,
    baseColor: baseColor ?? config.defaultBaseColor,
    highlightColor: highlightColor ?? config.defaultHighlightColor,
    shimmerDuration: shimmerDuration ?? config.defaultShimmerDuration,
    transitionDuration:
        transitionDuration ?? config.defaultTransitionDuration,
    child: child,
  );
}