Flutter:行中的两个Textformfield有问题

时间:2019-06-10 10:00:55

标签: flutter dart flutter-layout

This is the image of issue

我在颤振设计中面临问题 当我在一个textformfield上设置错误时,我连续有两个textformfield,它会稍微向上移动或缩小以为错误文本腾出空间

在android native中不存在此问题

请任何人能帮助我

我尝试了许多解决方案,例如将容器高度设置为100并在其中放置行并设置对齐中心,但没有找到解决方案

   final firstName = new TextFormField(
    decoration: InputDecoration(
   //          border: OutlineInputBorder(),
      labelText: _APP_FIRSTNAME_LBL,
      contentPadding:
          EdgeInsets.only(left: 0.0, top: 8.0, right: 0.0, bottom: 8.0)),
  validator: validateName,
  onSaved: (String val) {
    _mFirstName = val;
  },
);

 final lastName = new TextFormField(
    decoration: InputDecoration(
 //            border: OutlineInputBorder(),
        labelText: _APP_LASTNAME_LBL,
        contentPadding:
            EdgeInsets.only(left: 0.0, top: 8.0, right: 0.0, bottom: 
 8.0)),
    //obscureText: true,
    validator: validateName,
    onSaved: (String val) {
      _mLastName = val;
    });

  final rowFirstLastName = new Container(
    alignment: Alignment.center,
    height: 80,
    child: new Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: <Widget>[
        new Flexible(
          child: Padding(
            padding: const EdgeInsets.all(0.0),
            child: firstName,
          ),
        ),
        SizedBox(width: 48.0),
        new Flexible(
          child: Padding(
            padding: const EdgeInsets.all(0.0),
            child: lastName,
          ),
        ),
      ],
    ));

如果错误或未在字段上设置,则两个textformfield都应保持相同的对齐方式

1 个答案:

答案 0 :(得分:0)

尝试向您的TextFormField添加一个空helperText。它将在输入下方保留一个空间,并且在显示错误时,您的输入将不会更改大小。