dottedLine static method

Widget dottedLine({
  1. double height = .5,
  2. required Color color,
  3. EdgeInsets? margin,
})

Implementation

static Widget dottedLine({
  double height = .5,
  required Color color,
  EdgeInsets? margin,
}) {
  return Container(
    margin: margin,
    child: LayoutBuilder(
      builder: (BuildContext context, BoxConstraints constraints) {
        final boxWidth = constraints.constrainWidth();
        double dashWidth = 10.0.h;
        final dashHeight = height;
        final dashCount = (boxWidth / (2 * dashWidth)).floor();
        return Flex(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          direction: Axis.horizontal,
          children: List.generate(
            dashCount,
            (_) {
              return SizedBox(
                width: dashWidth,
                height: dashHeight,
                child: DecoratedBox(
                  decoration: BoxDecoration(color: color),
                ),
              );
            },
          ),
        );
      },
    ),
  );
}