将字符串列表转换为动态类型列表
convert a list of strings to list of type dynamic
我正在尝试使用 MultiSelectFormField 创建包含多个 choices.The 数据源的下拉列表,MultiSelectFormField 需要以下格式,
dataSource:[
{
"display": "Running",
"value": "Running",
},
{
"display": "Climbing",
"value": "Climbing",
},
{
"display": "Walking",
"value": "Walking",
},
],
但是我有一个字符串类型的列表,其中包含应该在下拉列表中显示的值 st down.My 问题是我如何转换
list<String> dropDownValues=["Running","Climbing","Walking"]
到要求的格式
请使用地图运算符
final dropDownValues=["Running","Climbing","Walking"];
final data = dropDownValues.map((el) => {"display": el,"value" el,}).toList();
我正在尝试使用 MultiSelectFormField 创建包含多个 choices.The 数据源的下拉列表,MultiSelectFormField 需要以下格式,
dataSource:[
{
"display": "Running",
"value": "Running",
},
{
"display": "Climbing",
"value": "Climbing",
},
{
"display": "Walking",
"value": "Walking",
},
],
但是我有一个字符串类型的列表,其中包含应该在下拉列表中显示的值 st down.My 问题是我如何转换
list<String> dropDownValues=["Running","Climbing","Walking"]
到要求的格式
请使用地图运算符
final dropDownValues=["Running","Climbing","Walking"];
final data = dropDownValues.map((el) => {"display": el,"value" el,}).toList();