颤振布局问题。如何让所有字段长度相同

问题描述 投票:1回答:1

我正在开发一个注册屏幕。我无法在屏幕上获得具有相同长度的所有字段。它们是不同类型的字段:ListTile,Dropdown按钮和Checkbox。我是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));
                  },
                ),

              ],
            ),
          ),
        ]
    ),
  );
}

任何帮助将不胜感激。问候。

flutter flutter-layout
1个回答
0
投票

用just替换你的ListTiles并注意icon属性。

TextField(
    decoration: InputDecoration(
        labelText: "Username : ",
        hintText: " Username ",
        icon: const Icon(Icons.person),
        errorText: _correctUsername ? null : 'Complete Username',
    ),
    onSubmitted: (value) {
        _checkInput();
    },
    controller: _usernameController,
),
© www.soinside.com 2019 - 2024. All rights reserved.