Want to change textField underline color in Flutter? The logical answer would be to use an InputBorder, particularly an UnderlineInputDecorator, and pass it in to the inputdecorator as the border. However, all this does is tell the InputDecorator whether is should use an underline or whatever else you specify.
1 2 3 4 5 6 7 8 9 10 11 |
Color _getActiveColor(ThemeData themeData) { if (isFocused) { switch (themeData.brightness) { case Brightness.dark: return themeData.accentColor; case Brightness.light: return themeData.primaryColor; } } return themeData.hintColor; } |
So to change the colour do something like this (or specify the theme for your entire application):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
new Theme( data: new ThemeData( primaryColor: Colors.red, accentColor: Colors.orange, hintColor: Colors.green ), child: new TextField( decoration: new InputDecoration( hintText: "Enter your email", labelText: "Email", labelStyle: new TextStyle(color: const Color(0xFF424242)), border: new UnderlineInputBorder( borderSide: new BorderSide( color: Colors.red ) ) ), ), ), |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.