textLines static method

Widget textLines({
  1. int lines = 2,
  2. double lineHeight = 14.0,
  3. double spacing = 8.0,
  4. bool lastLineShort = true,
  5. Color? staticColor,
  6. bool animated = true,
  7. Color? baseColor,
  8. Color? highlightColor,
})

Generates a layout of multiple skeleton text lines. Wraps all lines in a SINGLE shimmer so the sweep effect travels across them seamlessly.

Implementation

static Widget textLines({
  int lines = 2,
  double lineHeight = 14.0,
  double spacing = 8.0,
  bool lastLineShort = true,
  Color? staticColor,
  bool animated = true,
  Color? baseColor,
  Color? highlightColor,
}) {
  Widget content = Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    mainAxisSize: MainAxisSize.min,
    children: List.generate(lines, (index) {
      final isLast = index == lines - 1;
      return _buildShape(
        width: (isLast && lastLineShort) ? 120.0 : double.infinity,
        height: lineHeight,
        borderRadius: lineHeight / 2,
        color: staticColor,
        margin: EdgeInsets.only(bottom: isLast ? 0 : spacing),
      );
    }),
  );

  if (!animated) return content;
  return RistoShimmer(
    baseColor: baseColor,
    highlightColor: highlightColor,
    child: content,
  );
}