布局问题
来源:12-12 网格卡片功能实现&布局技巧-2【布局进阶】
qq_挂失的青春_0
2019-08-21
项目中使用FractionallySizedBox的目的是什么呢,项目中下面两段代码运行出来的效果一样,为什么要使用FractionallySizedBox呢?另外FractionallySizedBox和Expanded有什么区别?
_item(BuildContext context, CommonModel item, bool first) {
BorderSide borderSide = BorderSide(width: 0.8, color: Colors.white);
return Container(
decoration: BoxDecoration(
border: Border(
left: borderSide,
bottom: first ? borderSide : BorderSide.none,
)),
child: _wrapGesture(
context,
Center(
child: Text(
item.title,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: Colors.white),
),
),
item),
);
}
_item(BuildContext context, CommonModel item, bool first) {
BorderSide borderSide = BorderSide(width: 0.8, color: Colors.white);
return FractionallySizedBox(
//撑满父布局的宽度
widthFactor: 1,
child: Container(
decoration: BoxDecoration(
border: Border(
left: borderSide,
bottom: first ? borderSide : BorderSide.none,
)),
child: _wrapGesture(
context,
Center(
child: Text(
item.title,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: Colors.white),
),
),
item),
),
);
}
写回答
1回答
-
CrazyCodeBoy
2019-08-25
00
相似问题