flutter 画虚线
2022-03-25 本文已影响0人
心旷则神怡
import 'package:flutter/material.dart';
class DashedLine extends StatelessWidget {
final Axis axis;
final double dashedWidth;
final double dashedHeight;
final int count;
final Color color;
const DashedLine({
required this.axis,
required this.dashedWidth,
required this.dashedHeight,
this.color = Colors.red,
this.count = 10
}) ;
@override
Widget build(BuildContext context) {
return Flex(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
direction: axis,
children: List.generate(count, ( _) {
return SizedBox(
width: dashedWidth,
height: dashedHeight,
child: DecoratedBox(
decoration: BoxDecoration(color: color,)
),
);
}),
);
}
}