gpt4 book ai didi

flutter - 如何解决Flutter中的窗口小部件溢出问题?

转载 作者:行者123 更新时间:2023-12-03 03:25:41 25 4
gpt4 key购买 nike

我有一个问题的图像,溢出了17个像素。
&我无法解决?
首先,我做了.. !!!

我带了一个Row()小部件,并包裹了Container(),在其中Row()带了两个Expanded()小部件。一个用于TextField(),另一个用于CountryPickerDropdown()

enter image description here

我用过country_pickers插件

码:

 new Container(
width: MediaQuery.of(context).size.width,
padding: const EdgeInsets.only(left: 10.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5.0)),
border: Border.all(color: Colors.blue)
),
child: Row(
children: <Widget>[
Expanded(
child: CountryPickerDropdown(
initialValue: 'in',

itemBuilder: _buildDropdownItem,
onValuePicked: (Country country) {

isCountryCodeSelected=true;
print("${country.name}");
print("${country.phoneCode}");
print("${country.isoCode}");
print("+${country.phoneCode}(${country.isoCode})");
setState(() {
countryCode= country.phoneCode;
});
},
),
),
Expanded(
child: TextField(
keyboardType: TextInputType.phone,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Telephone Number",
),

onChanged: (value){

setState(() {
phoneValue=value;
});

print("phoneNumbe:$phoneNo");
this.phoneNo = isCountryCodeSelected ? "+" + countryCode + value : "+91" + value ;
print("phoneNo="+phoneNo);

},

),
)
],
)
),

Contry代码及其国旗图像的小部件:
 Widget _buildDropdownItem(Country country) => Container(
child: Row(
children: <Widget>[
CountryPickerUtils.getDefaultFlagImage(country),
SizedBox(
width: 8.0,
),
Text("+${country.phoneCode}(${country.isoCode})"),
],
),
);

最佳答案

怀疑您的countryselector小部件需要扩展子级,并且文本溢出。

 Widget _buildDropdownItem(Country country) =>  Row(
children: <Widget>[
Expanded(child: Container(
margin: EdgeInsets.only(right: 8),
child: CountryPickerUtils.getDefaultFlagImage(country)),),
Expanded(child: Text(
"+${country.phoneCode}(${country.isoCode})",
overflow: Overflow.Eclipse
),)
],

);

关于flutter - 如何解决Flutter中的窗口小部件溢出问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57754864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com