Skip to content

Instantly share code, notes, and snippets.

@JEuler
Last active April 6, 2020 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JEuler/4d4b84151115e418f1b8db76235049ac to your computer and use it in GitHub Desktop.
Save JEuler/4d4b84151115e418f1b8db76235049ac to your computer and use it in GitHub Desktop.
DotDivider widget for Flutter
import 'package:flutter/material.dart';
/// Dot divider for Calendar
class DotDivider extends StatelessWidget {
/// Constructor
const DotDivider(
{this.height = 1, this.color = Colors.black, this.countCoeff = 3});
/// Color of divider
final Color color;
/// Height of divider
final double height;
/// Dash count coefficient
final double countCoeff;
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
final boxWidth = constraints.constrainWidth();
const dashWidth = 2.0;
final dashHeight = height;
final dashCount = (boxWidth / (countCoeff * 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),
),
);
}),
);
},
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment