Is there a way to change TextField text input color from theme configuration in Flutter

Question

Asked by Samir A on November 12, 2021 (source).

I know there is a way to change text input color of TextField using the style: TextStyle() property, but I want to change the text color from the ThemeData widget, when first setting up the theme for the whole app MaterialApp(theme: ThemeData...). Is there anyway to do that?

Answer

Question answered by Yeasin S (source).

The default TextStyle for TextField is subtitle1. You can change it on theme level.

If style is null, defaults to the subtitle1 text style from the current [Theme].

 return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
          primarySwatch: Colors.blue,
          textTheme: Theme.of(context).textTheme.copyWith(
                subtitle1: const TextStyle(color: Colors.green),
              )),
      home: const MyHomePage(),
    );
DART FLUTTER
SHARE: