在flutter中,如何将TextFormField中的文本与后缀垂直对齐?

k10s72fa  于 2023-02-16  发布在  Flutter
关注(0)|答案(1)|浏览(180)

我希望我的表单文本垂直居中,并与后缀一致,因为它是恼人的我,它不是。
在我的InputDecoration中,我试着把contentPadding设置为EdgeInsets.zero,但是最后还是这样,我希望它能像第一个表单域一样,唯一的区别就是有后缀,下面是代码。

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: () => {},
              )),
        ),
      ],
    ),
  ),
);
c7rzv4ha

c7rzv4ha1#

您可以尝试将textAlignVertical: TextAlignVertical.center添加到您的TextFormField:

相关问题