Flutter 颤振:如何将“颤振”中的两个元素对齐;“世界其他地区”;在表格里?
我正在开发一个应用程序在颤振。为用户创建注册表单。我希望两个元素在同一行中以基线级别对齐,如下所示: 但在我的应用程序中,它看起来是这样的: 以下是我的具体行代码:Flutter 颤振:如何将“颤振”中的两个元素对齐;“世界其他地区”;在表格里?,flutter,flutter-layout,Flutter,Flutter Layout,我正在开发一个应用程序在颤振。为用户创建注册表单。我希望两个元素在同一行中以基线级别对齐,如下所示: 但在我的应用程序中,它看起来是这样的: 以下是我的具体行代码: Row( mainAxisAlignment: MainAxisAlignment.end, verticalDirection: Ver
Row(
mainAxisAlignment: MainAxisAlignment.end,
verticalDirection: VerticalDirection.down,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
DropdownButton(
hint: Text('Cod.'),
items: codeList,
value: selectedcode,
onChanged: (value) {
setState(() {
selectedcode = value;
});
},
style: TextStyle(
color: Colors.grey[600],
fontSize: scalador.setSp(22) * 2.63),
),
SizedBox(
width: scalador.setWidth(275) * 2.41,
child: TextFormField(
onChanged: (val) {
setState(() {
telefono = val;
});
},
decoration: InputDecoration(
hintText: "Telefono"),
keyboardType: TextInputType.phone,
style: TextStyle(
color: Colors.grey[600],
fontSize:
scalador.setSp(22) * 2.63),
validator: (value) {
if (value.isEmpty) {
return 'Por favor ingrese su telefono';
} else {
if (value.length < 8)
return 'El numero de telefono debe tener mas de 8 digitos';
}
return null;
}),
),
],
),
行(
mainAxisAlignment:mainAxisAlignment.end,
垂直方向:垂直方向。向下,
crossAxisAlignment:crossAxisAlignment.end,
儿童:[
下拉按钮(
提示:文本('Cod'),
项目:代码列表,
值:selectedcode,
一旦更改:(值){
设置状态(){
selectedcode=值;
});
},
样式:TextStyle(
颜色:颜色。灰色[600],
fontSize:scalador.setSp(22)*2.63),
),
大小盒子(
宽度:scalador.setWidth(275)*2.41,
子项:TextFormField(
一旦更改:(val){
设置状态(){
telefono=val;
});
},
装饰:输入装饰(
hintText:“Telefono”),
键盘类型:TextInputType.phone,
样式:TextStyle(
颜色:颜色。灰色[600],
字体大小:
scalador.setSp(22)*2.63),
验证器:(值){
if(value.isEmpty){
返回“喜欢安格尔苏电视台”;
}否则{
如果(值。长度<8)
返回“8位数字用户的电话号码”;
}
返回null;
}),
),
],
),
我怎样才能解决这个问题
编辑: 实现这种将Dropdownbutton添加到textformfield的方法,如下面的一些答案所示
TextFormField(
onChanged: (val) {
setState(() {
telefono = val;
});
},
decoration: InputDecoration(
hintText: "Telefono",
prefix: DropdownButton(
hint: Text('Cod.'),
items: codeList,
value: selectedcode,
onChanged: (value) {
setState(() {
selectedcode = value;
});
},
style: TextStyle(
color: Colors.grey[600],
fontSize:
scalador.setSp(22) * 2.63),
)),
keyboardType: TextInputType.phone,
style: TextStyle(
color: Colors.grey[600],
fontSize: scalador.setSp(22) * 2.63),
validator: (value) {
if (value.isEmpty) {
return 'Por favor ingrese su telefono';
} else {
if (value.length < 8)
return 'El numero de telefono debe tener mas de 8 digitos';
}
return null;
})
TextFormField(
一旦更改:(val){
设置状态(){
telefono=val;
});
},
装饰:输入装饰(
hintText:“Telefono”,
前缀:下拉按钮(
提示:文本('Cod'),
项目:代码列表,
值:selectedcode,
一旦更改:(值){
设置状态(){
selectedcode=值;
});
},
样式:TextStyle(
颜色:颜色。灰色[600],
字体大小:
scalador.setSp(22)*2.63),
)),
键盘类型:TextInputType.phone,
样式:TextStyle(
颜色:颜色。灰色[600],
fontSize:scalador.setSp(22)*2.63),
验证器:(值){
if(value.isEmpty){
返回“喜欢安格尔苏电视台”;
}否则{
如果(值。长度<8)
返回“8位数字用户的电话号码”;
}
返回null;
})
但是现在它看起来像这样,当你渲染界面时
下拉按钮在界面中不可见,但会占用您的空间。德埃斯塔·马内拉
您可以通过扩展来捕获文本字段。或者按容器设置屏幕80/90%的宽度,为按钮设置宽度,但为按钮设置宽度为屏幕宽度的10/20%。当
TextForField
提供此功能时,为什么要使用行
TextFormField(
decoration: InputDecoration(
prefix: //implement the drop down here
),
)
我实现了它,但现在的细节是,当我渲染select时,它看起来不可见,我必须触摸它才能显示出来。请看问题的版本