我正在使用flutter web并且我有一个TextFormField,当我设置isDense = true并添加contentPadding时,它不尊重内部文本大小的大小。因此将 contentPadding 设置为 EdgeInsets.only(top: 8),实际上并不会在文本顶部添加 8 个像素,而只是在垂直方向上为整个字段添加 8 个像素。
我如何设置尊重内部孩子的自定义填充,类似于何时可以在尊重内部孩子的 Container 小部件上设置“填充”属性。
TextFormField(
controller: controller,
obscureText: obscureText,
style: theme.textTheme.subtitle2,
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: theme.highlightColor),
),
border: OutlineInputBorder(),
isDense: true,
contentPadding: const EdgeInsets.only(left: 7, top: 7, bottom: 8), // this does respect inner text
labelText: this.placeholder,
floatingLabelBehavior: FloatingLabelBehavior.never,
labelStyle: theme.textTheme.subtitle2.apply(
color: theme.unselectedWidgetColor,
),
),
)