Is there any way in flutter to control the padding of error text and hint text separately in TextFormField? if not how can we make a custom and separate error text widget below TextFormField.


Solution 1: Harsh Sureja

Try this if could be help for you

class CustomTextFormFiled extends StatefulWidget {
  const CustomTextFormFiled({Key key}) : super(key: key);

  @override
  _CustomTextFormFiledState createState() => _CustomTextFormFiledState();
}

class _CustomTextFormFiledState extends State<CustomTextFormFiled> {

  bool isError = false;
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        TextFormField(
          onSaved: (value){

            if(value.isEmpty){
              isError=true;

            }
    },

        ),
        if(isError)...{
          const Padding(
            padding: EdgeInsets.all(10),
            child: Text("Error Details"),
          )
        }
      ],
    );
  }
}