79553943

Date: 2025-04-03 20:21:41
Score: 1.5
Natty:
Report link

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.

Reasons:
  • RegEx Blacklisted phrase (1.5): fixText?
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Harsh Jani