Want to change TextField’s Underline in Flutter? While these other answers may somehow work, you should definitely not use it. That’s not the proper way to get a custom theme in Flutter.
final theme = Theme.of(context);
return new Theme(
data: theme.copyWith(primaryColor: Colors.red),
child: new TextField(
decoration: new InputDecoration(
labelStyle: theme.textTheme.caption.copyWith(color: theme.primaryColor),
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.