如何在扑波中获取所选列表项目的价值

发布于 2025-02-13 08:29:29 字数 2739 浏览 0 评论 0原文

我已经列出了称为语言列表的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情归归情 2025-02-20 08:29:29

如果所选值是索引,那么您可以这样做

/*...*/
onSelect: (value) {
  value.forEach((v) => selectedLanguages.add(languagesList[v]));
}
/*...*/

以获取语言。

If the selected value is the index then you can do

/*...*/
onSelect: (value) {
  value.forEach((v) => selectedLanguages.add(languagesList[v]));
}
/*...*/

to get the languages.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文