比如我想把虚线显示在其父组件的底部
代码如下:
Widget MyWidgetsTest() {
//DashedLine(虚线)
LJDashedLine dashedLine = LJDashedLine(axis: Axis.horizontal);
Container dashedLineContainer = Container(
width: 200,
height: 100,
child: dashedLine,//虚线
color: Colors.yellow,
// alignment: Alignment.bottomLeft, //1.无效,不显示dashedLine
// padding: EdgeInsets.fromLTRB(0, 97, 0, 0),//2.这种倒是可以显示到底部
);
return dashedLineContainer;
}
class LJDashedLine extends StatelessWidget {
//...省略部分代码
@override
Widget build(BuildContext context) {
// TODO: implement build
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return Flex(
direction: this.axis,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
// mainAxisSize: MainAxisSize.min,
children: List.generate(CalcDashedCountWithConstraints(constraints), (int index) {
return SizedBox(
width: dashedWidth,
height: dashedHeight,
child: DecoratedBox(
decoration: BoxDecoration(color: dashedColor),
),
);
}),
);
},
);
}
}
如上,这样运行虚线默认是居中显示的,然后我想在dashedLine父组件Container中调整alignment: Alignment.bottomLeft让虚线显示在底部为啥虚线就直接不显示了呢....### 问题描述
没人吗,自己顶一下,虽然我知道有几种方法可以解决这个问题,但是我却不知道为啥Alignment.bottomLeft设置无效不说还把dashedLine给搞没了。。