lines static method

Widget lines({
  1. Key? key,
  2. int count = 3,
  3. double spacing = 8.0,
  4. double lineHeight = 14.0,
  5. double lastLineWidthRatio = 0.65,
  6. BorderRadius borderRadius = const BorderRadius.all(Radius.circular(4.0)),
  7. Color? color,
  8. Color? highlightColor,
  9. Duration duration = const Duration(milliseconds: 1500),
  10. bool loading = true,
})

Creates a multi-line paragraph placeholder.

The last line can be rendered shorter using lastLineWidthRatio (default: 0.65).

Implementation

static Widget lines({
  Key? key,
  int count = 3,
  double spacing = 8.0,
  double lineHeight = 14.0,
  double lastLineWidthRatio = 0.65,
  BorderRadius borderRadius = const BorderRadius.all(Radius.circular(4.0)),
  Color? color,
  Color? highlightColor,
  Duration duration = const Duration(milliseconds: 1500),
  bool loading = true,
}) {
  if (!loading) return const SizedBox.shrink();

  return Column(
    key: key,
    mainAxisSize: MainAxisSize.min,
    crossAxisAlignment: CrossAxisAlignment.start,
    children: List.generate(count, (index) {
      final isLast = index == count - 1;
      return Padding(
        padding: EdgeInsets.only(bottom: isLast ? 0.0 : spacing),
        child: FractionallySizedBox(
          widthFactor: isLast && count > 1 ? lastLineWidthRatio : 1.0,
          child: TSkeleton.text(
            height: lineHeight,
            borderRadius: borderRadius,
            color: color,
            highlightColor: highlightColor,
            duration: duration,
          ),
        ),
      );
    }),
  );
}