1

I am trying to style the border of TextFormField. I'm using it with an OutlineInputBorder. It by default takes an almost black color and on focus takes primary color. I tried to change color of the BorderSide but it ain't worked.

I also tried the workarounds mentioned at Change TextField's Underline in Flutter for UnderlineInputBorder, but nothing changes.

new TextFormField(
    decoration: new InputDecoration(
        labelText: "Email",
        contentPadding: new EdgeInsets.all(12.0),
        filled: true,
        border: new OutlineInputBorder(
            borderSide: new BorderSide(width: 2.0, color: Colors.white),
        )
    ),
),
Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
ryanafrish7
  • 3,222
  • 5
  • 20
  • 35

1 Answers1

2

After digging deep, it seems like it's only configurable by ThemeData. So I simply added a Theme widget.

body: Theme(data: Theme.of(context).copyWith(
          primaryColor: Colors.white,
          accentColor: Colors.amber
      ), child: new TextFormField(
          decoration: new InputDecoration(
          labelText: "Email",
          contentPadding: new EdgeInsets.all(12.0),
      ),
),

input_decorator.dart#1440-1450

Color _getActiveColor(ThemeData themeData) {
    if (isFocused) {
      switch (themeData.brightness) {
        case Brightness.dark:
          return themeData.accentColor;
        case Brightness.light:
          return themeData.primaryColor;
      }
    }
    return themeData.hintColor;
  }
ryanafrish7
  • 3,222
  • 5
  • 20
  • 35