To center text inside a TextFormField
, use the contentPadding
property of the InputDecoration
class.
Example:
decoration: InputDecoration(
counterText: counterText,
isDense: true,
filled: true,
contentPadding: EdgeInsets.all(8.0),
fillColor: Palette.textFieldBackground,
prefixIcon: prefixIcon,
suffixIcon: suffixIcon,
suffixText: suffixText?.tr,
prefixText: prefixText?.tr,
errorText: errorText?.tr,
hintText: hintText?.tr,
prefixIconConstraints: prefixIconConstraints,
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.all(Radius.circular(borderRadius))),
errorMaxLines: 3),
By adjusting the contentPadding
, you can control the vertical and horizontal positioning of the text inside the field.