SkeletonLoader constructor
SkeletonLoader({})
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,
);
}