how to remove error text below my textfield in flutter

Advertisements

hey i am trying to remove the error this condition is working for me to remove the error but it does not change border color border color still remain same means border color remain red so how to change the border color to normal color

TextField(
                controller: userName,
                onChanged: (value){},
                decoration: InputDecoration(
                  hintText: "Email",
                  errorText: valid == true ? "" : "Not Good",
                  errorStyle: TextStyle(fontSize: valid == true ? 0 : 12),
                  prefixIcon: const Icon(Icons.email),
                  border: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(10),
                    borderSide: BorderSide(color: valid == true ? Colors.black : Colors.red)
                  ),
                ),
              ),

>Solution :

did you use errorBorder

TextField(
  onChanged: (value) {},
  decoration: InputDecoration(
    errorBorder: const OutlineInputBorder(
      borderSide: BorderSide(color: Colors.red, width: 0.0),
    ),
    hintText: "Email",
    errorText: valid == true ? "email" : "Not Good",
    errorStyle: TextStyle(fontSize: valid == true ? 0 : 12),
    prefixIcon: const Icon(Icons.email),
    border: OutlineInputBorder(
        borderRadius: BorderRadius.circular(10),
        borderSide:
            BorderSide(color: valid == true ? Colors.black : Colors.blue)),
  ),
);

Leave a ReplyCancel reply