【发布时间】:2021-08-19 18:06:06
【问题描述】:
在 HTML 中,复选框具有名称、值和标签:
<input type="checkbox" id="fruit" name="fruits" value="small_apple"><label for="fruit">Small Apple</label>
<input type="checkbox" id="fruit" name="fruits" value="big_apple"><label for="fruit">Big Apple</label>
如果两者都被选中,一旦提交,我将得到一个名为 fruits 的数组,其中包含“small_apple”和“big_apple”。
Flutter CheckboxListTile 有一个出现在屏幕上的标题:
CheckboxListTile(
title: Text("Small Apple"),
value: value,
onChanged: (bool value) { ... },
)
我不需要在提交时发送“小苹果”,而是“小苹果”。 Flutter 中的“值”仅保持复选框状态(true/false),那么如何在 Flutter 中设置“值”,如 HTML 呢?或者我必须在提交之前将“Small Apple”转换为“small_apple”?
【问题讨论】:
标签: flutter