[英]Flutter: How to remove extra paddings of checkbox (multiple CheckboxListTile)?
I am trying to create a checkbox list like this: my plan我正在尝试创建一个这样的复选框列表:我的计划
I used CheckBoxListTile
with dense
and contentPadding
to remove all possible paddings, and this is what I have: my result我将
CheckBoxListTile
与dense
和contentPadding
一起使用来删除所有可能的填充,这就是我所拥有的:我的结果
Is there any way to remove the extra "padding" between CheckBoxListTile
?有什么方法可以删除
CheckBoxListTile
之间的额外“填充”?
Here is my code (a single checkbox):这是我的代码(一个复选框):
class Checklist extends StatefulWidget {
Checklist({@required this.content});
final String content;
@override
_ChecklistState createState() => _ChecklistState();
}
class _ChecklistState extends State<Checklist> {
bool _checked = false;
@override
Widget build(BuildContext context) {
return CheckboxListTile(
contentPadding: EdgeInsets.all(0),
//dense: true,
title: Text(widget.content, style: TextStyle(color: kBlackColor),),
value: _checked,
onChanged: (bool value) {
setState(() {
_checked = value;
});
},
controlAffinity: ListTileControlAffinity.leading,
activeColor: kBlackColor,
);
}
}
Multiple checkboxes:多个复选框:
Column(
children: [
Checklist(content: 'Develop an app'),
Checklist(content: 'Develop a good app'),
Checklist(content: 'Develop a really good app'),
],
),
wrap your CheckBox inside SizedBox will resize the padding of the check box将 CheckBox 包裹在 SizedBox 内将调整复选框的填充大小
SizedBox(
height: whatYouWant,
width: whatYouWant,
child: Checkbox(...),
)
please check this solution: https://stackoverflow.com/a/59420505/11989529请检查此解决方案: https : //stackoverflow.com/a/59420505/11989529
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.