我正在开发注册屏幕。 我无法在屏幕上获得具有相同长度的所有字段。 它们是字段的不同类型:ListTile,下拉按钮和复选框。我是Flutter的新手。我可以应用任何参数在两侧获得相同的填充吗?
@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));
},
),
],
),
),
]
),
);
}
任何帮助将不胜感激。 问候。
答案 0 :(得分:0)
用just替换您的ListTile
,并注意icon
属性。
TextField(
decoration: InputDecoration(
labelText: "Username : ",
hintText: " Username ",
icon: const Icon(Icons.person),
errorText: _correctUsername ? null : 'Complete Username',
),
onSubmitted: (value) {
_checkInput();
},
controller: _usernameController,
),