Hal*_*ynh 5 checkbox flutter flutter-layout flutter-theme
这是我在颤动中用于复选框的内容。但我只能为未选中状态设置边框颜色,而不能为复选框内的填充颜色找到方法。请在这件事上给予我帮助。
Theme(
data: ThemeData(unselectedWidgetColor: Colors.white),
child: Checkbox(
checkColor: Colors.blue,
activeColor: Colors.white,
value: rememberMe,
onChanged: (value) {
setState(() {
rememberMe = value;
});
},
),
)
Run Code Online (Sandbox Code Playgroud)
这与设计本身更相关。空复选框应该就是空的。如果你给它填充颜色,你就违背了设计目的。
无论如何,您可以通过将其放入Container具有背景颜色和宽度和高度的 a 中来实现此目的CheckBox:
return Center(
child: Container(
alignment: Alignment.center,
width: 14,
height: 14,
color: Colors.blue,
child: Checkbox(
checkColor: Colors.blue,
activeColor: Colors.white,
value: rememberMe,
onChanged: (value) {
setState(() {
rememberMe = value;
});
},
),
),
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6176 次 |
| 最近记录: |