如何在扑波中获取所选列表项目的价值
我已经列出了称为语言列表的langugages的自定义列表
List<String> languagesList = [
"English",
"German",
"Spanish",
"French",
"Italian",
"Portuguese",
"Latin",
"Urdu",
"Hindi",
"Chinese",
"Japanese"
];
,我正在使用 gf multi Select 从下拉列表中选择值。现在,我希望将值发送到firebase,为此,我制作了一个我使用的firebase查询的按钮,但是来自所选列表的值是索引,而不是来自列表的实际语言名称。我是新手,我不知道为什么以及如何做。如果有人知道,请告诉我。
空列表选择的语言是
List <dynamic> selectedLanguages = [];
我的其余代码:
GFMultiSelect(
items: dropList,
onSelect: (value) {
selectedLanguages = value;
print(selectedLanguages);
},
dropdownTitleTileText:
'Select your preferred languages',
dropdownTitleTileColor: Colors.white,
dropdownTitleTileMargin:
const EdgeInsets.only(top: 5, bottom: 5),
dropdownTitleTilePadding: const EdgeInsets.all(10),
dropdownUnderlineBorder: const BorderSide(
color: Colors.transparent, width: 2),
dropdownTitleTileBorder:
Border.all(color: Colors.grey, width: 1),
dropdownTitleTileBorderRadius:
BorderRadius.circular(5),
expandedIcon: const Icon(
Icons.keyboard_arrow_down,
color: Colors.black54,
),
collapsedIcon: const Icon(
Icons.keyboard_arrow_up,
color: Colors.black54,
),
submitButton: const Text('Select'),
dropdownTitleTileTextStyle: const TextStyle(
fontSize: 14, color: Colors.black54),
padding: const EdgeInsets.all(6),
margin: const EdgeInsets.all(6),
type: GFCheckboxType.custom,
customBgColor: const Color(0xFF2a3b6a),
activeBgColor: const Color(0xFF2a3b6a),
buttonColor: const Color(0xFF2a3b6a),
inactiveBorderColor: Colors.grey,
),
I have made a custom list of langugages named as languagesList like this
List<String> languagesList = [
"English",
"German",
"Spanish",
"French",
"Italian",
"Portuguese",
"Latin",
"Urdu",
"Hindi",
"Chinese",
"Japanese"
];
and I am using GF Multi Select to select the values from the dropdown. Now I want the values to be sent to firebase and for that I have made a button on which I've used firebase query but the value coming from the selected list is index only not the actual language name coming from list. I am a newbie I don't know why and how to do it. If anyone knows then please let me know.
The empty List selectedlanguages is
List <dynamic> selectedLanguages = [];
Here's the rest of my code:
GFMultiSelect(
items: dropList,
onSelect: (value) {
selectedLanguages = value;
print(selectedLanguages);
},
dropdownTitleTileText:
'Select your preferred languages',
dropdownTitleTileColor: Colors.white,
dropdownTitleTileMargin:
const EdgeInsets.only(top: 5, bottom: 5),
dropdownTitleTilePadding: const EdgeInsets.all(10),
dropdownUnderlineBorder: const BorderSide(
color: Colors.transparent, width: 2),
dropdownTitleTileBorder:
Border.all(color: Colors.grey, width: 1),
dropdownTitleTileBorderRadius:
BorderRadius.circular(5),
expandedIcon: const Icon(
Icons.keyboard_arrow_down,
color: Colors.black54,
),
collapsedIcon: const Icon(
Icons.keyboard_arrow_up,
color: Colors.black54,
),
submitButton: const Text('Select'),
dropdownTitleTileTextStyle: const TextStyle(
fontSize: 14, color: Colors.black54),
padding: const EdgeInsets.all(6),
margin: const EdgeInsets.all(6),
type: GFCheckboxType.custom,
customBgColor: const Color(0xFF2a3b6a),
activeBgColor: const Color(0xFF2a3b6a),
buttonColor: const Color(0xFF2a3b6a),
inactiveBorderColor: Colors.grey,
),
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果所选值是索引,那么您可以这样做
以获取语言。
If the selected value is the index then you can do
to get the languages.