You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
1.2 KiB

import 'package:flutter/material.dart';
class MySeparator extends StatelessWidget {
final double height;
final double width;
final Color color;
const MySeparator(
{this.height = 1, this.width = 1, this.color = Colors.black});
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
final boxWidth = constraints.constrainWidth();
final boxHeight = constraints.constrainHeight();
final dashWidth = width;
final dashHeight = height;
var dashCount = 1;
if (width > height) {
dashCount = (boxWidth / (2 * dashWidth)).floor();
} else {
dashCount = (boxHeight / (2 * dashHeight)).floor();
}
return Flex(
children: List.generate(dashCount, (_) {
return SizedBox(
width: dashWidth,
height: dashHeight,
child: DecoratedBox(
decoration: BoxDecoration(color: color),
),
);
}),
mainAxisAlignment: MainAxisAlignment.spaceBetween,
direction: width > height ? Axis.horizontal : Axis.vertical,
);
},
);
}
}