material-design – How to change the border color of a TextFormField?

Question:

I would like to change the TextFormField border color in the login screen to white because the background is gradient and it would be easier to see the text. Today I'm using the pattern I created for the theme:

ThemeData buildTheme() {
  final ThemeData base = ThemeData();

  return base.copyWith(
    primaryColor: Colors.lightBlue,
    inputDecorationTheme: InputDecorationTheme(
      border: OutlineInputBorder(),
    ),
  );
}

And I tried to create a decoration on the field:

final password = TextFormField(
  autofocus: false,
  obscureText: true,
  decoration: InputDecoration(
    labelText: 'Senha',
    border: OutlineInputBorder(
      borderSide: BorderSide(
        color: Colors.white,
      ),
    )
  ),
);

But I was not successful. How can I do this just for the fields on this screen?

Answer:

To solve this problem I created a new theme for the TextFormField in question:

final password = new Theme(
  data: new ThemeData(
    hintColor: Colors.white,
  ),
  child: TextFormField(
    autofocus: false,
    obscureText: true,
    decoration: InputDecoration(
      labelText: 'Senha',
      border: OutlineInputBorder(),
    ),
  ),
);
Scroll to Top
AllEscort