Flutter Form Builder Radio Group 没有选项标签
在 flutter 应用程序中,我使用 flutter_form_builder 在更新表单中实现 FormBuilderRadioGroup。
我有一个用于用户角色的整数字段和一个我想在表单中设置的布尔字段用户活动。在单选按钮组和下拉小部件中,只有一个值选项,而不是预期的标签/值对。
有没有简单的方法来处理这个问题而不是围绕它编写代码?
这是我的代码,这些值作为整数而不是字符串存储在我的数据库中
FormBuilderRadioGroup(
name: "role",
decoration: InputDecoration(
labelText: "Role",
labelStyle: TextStyle(color: personLabelColor, fontSize: _user.fontsize, fontWeight: FontWeight.normal)
),
options: const [
FormBuilderFieldOption(value: "Role1"),
FormBuilderFieldOption(value: "Role2"),
FormBuilderFieldOption(value: "Role3"),
FormBuilderFieldOption(value: "Role4"),
FormBuilderFieldOption(value: "Role5"),
FormBuilderFieldOption(value: "Role6"),
],
initialValue: _person.role,
),
In a flutter app I using flutter_form_builder to implement a FormBuilderRadioGroup in a update form.
I have an integer field for user role and a boolean field user active which I want to set in a form. In both the radio group and drop down widgets there is only one option for a value instead of the expected label / value pair.
Is there any easy way to handle this rather than code around it?
Here is my code, the values are stored in my database as integers, not strings
FormBuilderRadioGroup(
name: "role",
decoration: InputDecoration(
labelText: "Role",
labelStyle: TextStyle(color: personLabelColor, fontSize: _user.fontsize, fontWeight: FontWeight.normal)
),
options: const [
FormBuilderFieldOption(value: "Role1"),
FormBuilderFieldOption(value: "Role2"),
FormBuilderFieldOption(value: "Role3"),
FormBuilderFieldOption(value: "Role4"),
FormBuilderFieldOption(value: "Role5"),
FormBuilderFieldOption(value: "Role6"),
],
initialValue: _person.role,
),
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论