问题出现场景:
当我在画一个左右中的布局,中间是渐变的一个container,左右是图片的时候,左边出现有一条白色边线,导致不举不衔接;如下图
拼之前:
拼之后: 可以很明显看到有一条边 导致布局衔接不好
return Row(
children: [
Image.asset(
'lib/assets/images/scan/filename-left.png',
width: 32.px,
height: 32.px,
),
Container(
height: 32.px,
padding: EdgeInsets.symmetric(horizontal: 20.px),
alignment: Alignment.center,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [hexColor('#4EBAFF'), hexColor('#86DEFF')])),
child: Text(
'市场部采购需求单.pdf',
style: BaseStyle.style16('#ffffff'),
)),
Image.asset('lib/assets/images/scan/filename-right.png',
width: 32.px, height: 32.px)
],
);
问题解决:
设置 container 的border的宽度 width为0 就可以完美解决
return Row(
children: [
Image.asset('lib/assets/images/scan/filename-left.png',width: 32.px,height: 32.px,),
Container(
height: 32.px,
padding: EdgeInsets.symmetric(horizontal:20.px ),
alignment: Alignment.center,
decoration: BoxDecoration(
//这里设置border width 为0,颜色也设置成左边的颜色 可以完美衔接
border: Border(
left: BorderSide(color: hexColor('#4EBAFF'), width: 0.0)),
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [hexColor('#4EBAFF'), hexColor('#86DEFF')])),
child: Text(
'市场部采购需求单.pdf',
style: BaseStyle.style16('#ffffff'),
)),
Image.asset('lib/assets/images/scan/filename-right.png',width: 32.px,height: 32.px)
],
);
设置完之后的效果