如何在 flutter 中选择代码和国家名称下拉按钮后正确显示,其次如何在该代码中添加搜索栏?(下面给出的代码)

问题描述 投票:0回答:0
[[enter image description here](https://i.stack.imgur.com/4McwS.jpg)](https://i.stack.imgur.com/9EcQK.jpg)


child: DropdownButtonHideUnderline(
                    child: DropdownButton(
                      onTap: () {
                        if(((countryListModel?.countriesData??[]).isEmpty)){
                          commanDataService.countryList().then((value) {
                            if((value?.status??false)){
                              setState(() {
                                countryListModel = value;
                              }
                              );
                            }
                          });
                        }

                      },
                      hint: _dropDownCountrCodeValue == null
                          ? const Text('Select Country',style: TextStyle(fontFamily: 'Poppins',))
                          : Text(
                        _dropDownCountrCodeValue?.countryCode??"",
                        style: const TextStyle(fontFamily: 'Poppins',color: Colors.black38),
                      ),
                      isExpanded: true,
                      iconSize: 30.0,
                      style: const TextStyle(fontFamily: 'Poppins',color: Colors.grey),
                      items: (countryListModel?.countriesData??[]).map<DropdownMenuItem<CountriesData>>((CountriesData val) {

                        return DropdownMenuItem<CountriesData>(
                          value: val,
                          child: Text('( + ${val.phoneCode??""} ) ${val.countryName??""}',style: const TextStyle(fontFamily: 'Poppins',)),
                        );
                      },
                      ).toList(),
                      onChanged: (val) {
                        setState(
                              () {
                            _dropDownCountrCodeValue = val as CountriesData?;

                          },
                        );
                      },
                    ),
                  ),

我正在尝试正确显示完整的国家名称和代码,但仅显示国家/地区示例的缩写形式 +91 INDIA 但仅显示 (IN) 并尝试在此代码中添加搜索栏。

flutter flutter-dependencies flutter-animation
© www.soinside.com 2019 - 2024. All rights reserved.