toSkeletonBox method

Widget toSkeletonBox({
  1. SkeletonConfig? config,
  2. double? aspectRatio,
})

Creates a skeleton box matching this image's dimensions.

Implementation

Widget toSkeletonBox({
  SkeletonConfig? config,
  double? aspectRatio,
}) {
  final effectiveConfig = config ?? SkeletonConfig.defaultConfig;

  // If width and height are specified, use them
  if (width != null && height != null) {
    return SkeletonContainer(
      width: width,
      height: height,
      config: effectiveConfig,
    );
  }

  // Otherwise use aspect ratio
  if (aspectRatio != null) {
    return SkeletonBox(
      config: effectiveConfig,
      aspectRatio: aspectRatio,
    );
  }

  // Default square
  return SkeletonBox(
    config: effectiveConfig,
    aspectRatio: 1.0,
  );
}