40 lines
1022 B
Dart
40 lines
1022 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class DashedDivider extends StatelessWidget {
|
|
final double height;
|
|
final double dashWidth;
|
|
final double dashSpacing;
|
|
final Color color;
|
|
|
|
const DashedDivider({
|
|
super.key,
|
|
this.height = 1,
|
|
this.dashWidth = 5,
|
|
this.dashSpacing = 3,
|
|
this.color = Colors.grey,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
height: height,
|
|
child: LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
final boxWidth = constraints.constrainWidth();
|
|
final dashCount = (boxWidth / (dashWidth + dashSpacing)).floor();
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: List.generate(dashCount, (_) {
|
|
return SizedBox(
|
|
width: dashWidth,
|
|
height: height,
|
|
child: DecoratedBox(decoration: BoxDecoration(color: color)),
|
|
);
|
|
}),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|