56

Unable to change the default border color when TextFormField is not active. When TextFormField is not active this shows DarkGrey-Border color. So, how to change that.

enter image description here

Theme(
              data: new ThemeData(
                primaryColor: Colors.red,
                primaryColorDark: Colors.black,
              ),
              child: TextFormField(
                decoration: new InputDecoration(
                  labelText: "Enter Email",
                  fillColor: Colors.white,
                  border: new OutlineInputBorder(
                    borderRadius: new BorderRadius.circular(25.0),
                    borderSide: new BorderSide(),
                  ),
                  //fillColor: Colors.green
                ),
                validator: (val) {
                  if (val.length == 0) {
                    return "Email cannot be empty";
                  } else {
                    return null;
                  }
                },
                keyboardType: TextInputType.emailAddress,
                style: new TextStyle(
                  fontFamily: "Poppins",
                ),
              ),
            ),
diegoveloper
  • 93,875
  • 20
  • 236
  • 194
jazzbpn
  • 6,441
  • 16
  • 63
  • 99

2 Answers2

144

Use enabledBorder of the InputDecoration, don't forget you can also use the focusedBorder, like this :

InputDecoration(
                labelText: "Enter Email",
                fillColor: Colors.white,
                focusedBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(25.0),
                  borderSide: BorderSide(
                    color: Colors.blue,
                  ),
                ),
                enabledBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(25.0),
                  borderSide: BorderSide(
                    color: Colors.red,
                    width: 2.0,
                  ),
                ),
)

Here you have more info: https://api.flutter.dev/flutter/material/InputDecoration/enabledBorder.html

diegoveloper
  • 93,875
  • 20
  • 236
  • 194
0
    OutlineInputBorder(
                    borderSide: BorderSide(
                    color: AppColor.secondaryBackground)),
                    focusedBorder: OutlineInputBorder(
                    borderSide: BorderSide(color: 
                    AppColor.secondaryBackground)),
                    enabledBorder: OutlineInputBorder(
                    borderSide:  BorderSide(color: 
                    AppColor.secondaryBackground),
    ),
HannesH
  • 932
  • 2
  • 12
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 11 '23 at 11:00