Flutter 颤振布局问题。如何使所有字段的长度相同
我正在开发一个注册屏幕。 我无法在屏幕上获得所有长度相同的字段。 它们是不同类型的字段:ListTile、下拉按钮和复选框。我是个新手。我可以应用任何参数来获得两侧相同的填充吗Flutter 颤振布局问题。如何使所有字段的长度相同,flutter,flutter-layout,Flutter,Flutter Layout,我正在开发一个注册屏幕。 我无法在屏幕上获得所有长度相同的字段。 它们是不同类型的字段:ListTile、下拉按钮和复选框。我是个新手。我可以应用任何参数来获得两侧相同的填充吗 @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text("Register"), ), body: new Stack(
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Register"),
),
body: new Stack(
children: [
new Padding(
padding: const EdgeInsets.only(
left: 16.0, top: 30.0, right: 16.0, bottom: 16.0),
child: ListView(
children: <Widget>[
new ListTile(
leading: const Icon(Icons.person),
title: TextField(
decoration: InputDecoration(
labelText: "Username : ", hintText: " Username ",
errorText: _correctUsername ? null : 'Complete Username',),
onSubmitted: (value) {
_checkInput();
},
controller: _usernameController,
),
),
new FormField(
builder: (FormFieldState state) {
return InputDecorator(
decoration: InputDecoration(
icon: const Icon(Icons.person),
labelText: 'Gender',
errorText: _correctGender ? null : 'Select Gender',),
child: new DropdownButtonHideUnderline(
child: new DropdownButton(
value: _selectedGender,
items: _dropDownMenuGender,
onChanged: changedDropDownGender,
),
),
);
},
),
new ListTile(
leading: const Icon(Icons.person),
title: TextField(
decoration: InputDecoration(
labelText: "About me : ", hintText: " About me "),
controller: _aboutController,
),
),
new FormField(
builder: (FormFieldState state) {
return InputDecorator(
decoration: InputDecoration(
icon: const Icon(Icons.person),
labelText: 'I have a car',
),
child: new Checkbox(
value: _havecar, onChanged: _havecarChanged));
},
),
],
),
),
]
),
);
}
@覆盖
小部件构建(构建上下文){
归还新脚手架(
appBar:新的appBar(
标题:新文本(“登记册”),
),
正文:新堆栈(
儿童:[
新填料(
填充:仅限常量边设置(
左:16.0,顶部:30.0,右:16.0,底部:16.0),
子:ListView(
儿童:[
新ListTile(
前导:常量图标(Icons.person),
标题:文本字段(
装饰:输入装饰(
labelText:“用户名:”,hintText:“用户名”,
errorText:_correctUsername?null:“完整用户名”,),
提交:(值){
_checkInput();
},
控制器:\ u usernameController,
),
),
新FormField(
生成器:(FormFieldState){
返回输入装饰器(
装饰:输入装饰(
图标:常量图标(Icons.person),
标签文字:“性别”,
errorText:_correctGender?null:“选择性别”,),
子项:新的下拉按钮hideUnderline(
孩子:新的下拉按钮(
值:_selectedGender,
项目:_dropDownMenuGender,
onChanged:changedDropDownGender,
),
),
);
},
),
新ListTile(
前导:常量图标(Icons.person),
标题:文本字段(
装饰:输入装饰(
labelText:“关于我:”,hintText:“关于我”),
控制器:\关于控制器,
),
),
新FormField(
生成器:(FormFieldState){
返回输入装饰器(
装饰:输入装饰(
图标:常量图标(Icons.person),
labelText:“我有一辆车”,
),
子项:新复选框(
值:_havecar,一旦更改:_havecarChanged));
},
),
],
),
),
]
),
);
}
任何帮助都将不胜感激。
注意。用just替换您的
列表磁贴
s,并注意图标
属性
TextField(
decoration: InputDecoration(
labelText: "Username : ",
hintText: " Username ",
icon: const Icon(Icons.person),
errorText: _correctUsername ? null : 'Complete Username',
),
onSubmitted: (value) {
_checkInput();
},
controller: _usernameController,
),
与其在
列表中使用文本字段
作为标题
,不如使用行
。