如何修复国家/地区选择器布局,请"flutter"



在这一部分,我有一个问题,我需要自定义国家/地区选择器的方法,我试图用不同的方法解决它,但它不起作用
我不知道如何克服它

Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.black, width: 1)),
child: CountryCodePicker(
onChanged: (country) {
setState(() {
dialCodeDigits = country.dialCode!;
});
},
initialSelection: 'دولة الإمارات العربية المتحدة',
showCountryOnly: true,
showOnlyCountryWhenClosed: true,
favorite: ['+971', 'UAE', '+966', 'KSA'],
//padding: EdgeInsets.symmetric(horizontal: 
),
textStyle: TextStyle(
color: Color(0xff000000),
fontSize: 14,
wordSpacing: 5),
enabled: true,
// alignLeft: false,
flagWidth: 28,
padding: EdgeInsets.symmetric(horizontal: 25),
),
),

使用此程序包country_picker。它有一个名为phoneCode的字段。

TextField(
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(
vertical: 15.0, horizontal: 15),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Colors.white,
width: 1,
),
),
prefixIcon: TextButton(
onPressed: () {
showCountryPicker(
context: context,
onSelect: (value) {
setState(
() {
_selectedCountry = value;
},
);
},
);
},
child: Text(
"${_selectedCountry.flagEmoji} +${_selectedCountry.phoneCode}",
),
),
hintText: "Enter Phone Number",
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
),
),

国家的初始值设置为阿富汗。

Country _selectedCountry = Country.from(
json: {
"e164_cc": "93",
"iso2_cc": "AF",
"e164_sc": 0,
"geographic": true,
"level": 1,
"name": "Afghanistan",
"example": "701234567",
"display_name": "Afghanistan (AF) [+93]",
"full_example_with_plus_sign": "+93701234567",
"display_name_no_e164_cc": "Afghanistan (AF)",
"e164_key": "93-AF-0"
});

最新更新