我正在玩复选框,看看它是如何工作的,但我没有看到标题选项.
Checkbox(
title: Text("Checkbox label"), // The named parameter 'title' isn't defined.
value: true,
onChanged: (newValue) { },
);
我必须创建自己的小部件才能添加标题吗?
我正在玩复选框,看看它是如何工作的,但我没有看到标题选项.
Checkbox(
title: Text("Checkbox label"), // The named parameter 'title' isn't defined.
value: true,
onChanged: (newValue) { },
);
我必须创建自己的小部件才能添加标题吗?
如果您需要带标签的Checkbox
,那么您可以使用CheckboxListTile
.
CheckboxListTile(
title: Text("title text"), // <-- label
value: checkedValue,
onChanged: (newValue) { ... },
)
如果想要文本左侧的复选框,则可以设置controlAffinity
参数.
CheckboxListTile(
title: Text("title text"),
value: checkedValue,
onChanged: (newValue) { ... },
controlAffinity: ListTileControlAffinity.leading, // <-- leading Checkbox
)
onChanged()
回调.不过,您需要自己用正确的判断值重新构建它.见this answer.onChanged()
回调.你可以从CheckboxListTile
source code开始作为参考.