您如何垂直对齐TextFormField中带有后缀的文本?

时间:2019-08-26 14:06:24

标签: flutter

我希望表单文本垂直居中并与后缀对齐,因为这让我很烦,不是。

在我的InputDecoration内,我尝试将contentPadding设置为EdgeInsets.zero,但最终还是这样做了。 actual result我希望它像第一个表单字段一样,唯一的区别是在那里有后缀。这是代码。

return Form(
  key: _addSubjectFormKey,
  child: Padding(
    padding: const EdgeInsets.all(16.0),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        TextFormField(
          textCapitalization: TextCapitalization.words,
          autofocus: true,
          decoration: InputDecoration(
            filled: true,
            hintText: 'Enter subject name',
          ),
          textInputAction: TextInputAction.next,
        ),
        SizedBox(height: 20.0),
        TextFormField(
          textCapitalization: TextCapitalization.words,
          autofocus: false,
          keyboardType: TextInputType.text,
          textInputAction: TextInputAction.next,
          decoration: InputDecoration(
              contentPadding: EdgeInsets.zero,
              filled: true,
              hintText: 'Enter your name',
              suffix: IconButton(
                icon: Icon(Icons.keyboard),
                onPressed: () => {},
              )),
        ),
      ],
    ),
  ),
);

0 个答案:

没有答案