card static method

Widget card({
  1. Key? key,
  2. double? width,
  3. double? height,
  4. EdgeInsetsGeometry padding = const EdgeInsets.all(16.0),
  5. EdgeInsetsGeometry? margin = const EdgeInsets.only(bottom: 8.0),
  6. bool hasAvatar = true,
  7. double avatarSize = 40.0,
  8. int lines = 2,
  9. BorderRadius borderRadius = const BorderRadius.all(Radius.circular(10.0)),
  10. Color? color,
  11. Color? highlightColor,
  12. Duration duration = const Duration(milliseconds: 1500),
  13. bool loading = true,
})

Creates a card skeleton with an optional avatar and text lines.

Implementation

static Widget 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,
}) {
  if (!loading) return const SizedBox.shrink();

  return Container(
    key: key,
    width: width,
    height: height,
    margin: margin,
    padding: padding,
    decoration: BoxDecoration(
      borderRadius: borderRadius,
      border: Border.all(
        color: (color ?? Colors.grey).withValues(alpha: 0.15),
        width: 1.0,
      ),
    ),
    child: Column(
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        if (hasAvatar)
          Row(
            children: [
              TSkeleton.circle(
                size: avatarSize,
                color: color,
                highlightColor: highlightColor,
                duration: duration,
              ),
              const SizedBox(width: 12.0),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    TSkeleton.text(
                      width: 140.0,
                      height: 14.0,
                      color: color,
                      highlightColor: highlightColor,
                      duration: duration,
                    ),
                    const SizedBox(height: 6.0),
                    TSkeleton.text(
                      width: 90.0,
                      height: 11.0,
                      color: color,
                      highlightColor: highlightColor,
                      duration: duration,
                    ),
                  ],
                ),
              ),
            ],
          ),
        if (hasAvatar && lines > 0) const SizedBox(height: 16.0),
        if (lines > 0)
          TSkeleton.lines(
            count: lines,
            spacing: 8.0,
            lineHeight: 12.0,
            color: color,
            highlightColor: highlightColor,
            duration: duration,
          ),
      ],
    ),
  );
}