TextFormField Border color does not change

Issue

    TextFormField(
          decoration: InputDecoration(
            labelText: 'Ürün',
            labelStyle: TextStyle(fontFamily: 'Montserrat'),
            prefixIcon: Icon(
              Icons.shopping_basket,
              color: Color.fromARGB(255, 121, 171, 245),
            ),
            border: OutlineInputBorder(
                borderRadius: BorderRadius.circular(10.0),
                borderSide: BorderSide(color: Colors.green, width: 3),
                gapPadding: 20.0),
          ),
        )

I’m trying to change the border color of OutlineInputBorder with this code but it doesn’t change. It doesn’t increase the width of the sides either.

Solution

You try to just set border, but you should also set enableBorder and focusedBorder too, Set these in Theme data like this:

Theme(
            data: ThemeData(
              inputDecorationTheme: InputDecorationTheme(
                border: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(10.0),
                  borderSide: BorderSide(color: Colors.green, width: 3),
                  gapPadding: 20.0,
                ),
                enabledBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(10.0),
                  borderSide: BorderSide(color: Colors.green, width: 3),
                  gapPadding: 20.0,
                ),
                focusedBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(10.0),
                  borderSide: BorderSide(color: Colors.green, width: 3),
                  gapPadding: 20.0,
                ),
              ),
            ),
            child: TextFormField(
              decoration: InputDecoration(
                labelText: 'Ürün',
                labelStyle: TextStyle(fontFamily: 'Montserrat'),
                prefixIcon: Icon(
                  Icons.shopping_basket,
                  color: Color.fromARGB(255, 121, 171, 245),
                ),
                
              ),
            ),
          ),

enter image description here

Answered By – eamirho3ein

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published