How can I change the color of an string-input in a TextField?

You can assign a TextStyle

TextField(
  style: TextStyle(color: Colors.white),
  ...
)

https://docs.flutter.io/flutter/painting/TextStyle-class.html


In the example bellow, text is 'red' and the background of the TextField is 'orange'.

TextField(
  style: TextStyle(color: Colors.red),
  decoration: InputDecoration(fillColor: Colors.orange, filled: true),
)

Is that what you mean?

If you want to do it generically through the app's theme, it's indeed tricky. It's probably going to be something like that:

theme: ThemeData(
    textTheme: TextTheme(
      bodyText1: TextStyle(color: Colors.black),
      bodyText2: TextStyle(color: Colors.black),
      button: TextStyle(color: Colors.black),
      caption: TextStyle(color: Colors.black),
      subtitle1: TextStyle(color: Colors.red), // <-- that's the one
      headline1: TextStyle(color: Colors.black),
      headline2: TextStyle(color: Colors.black),
      headline3: TextStyle(color: Colors.black),
      headline4: TextStyle(color: Colors.black),
      headline5: TextStyle(color: Colors.black),
      headline6: TextStyle(color: Colors.black),
    ),
    inputDecorationTheme: InputDecorationTheme(
      fillColor: Colors.orange,
      filled: true,
    )
)

To change it in ThemeData I used:

ThemeData(
      textTheme: TextTheme(subtitle1: TextStyle(color: Colors.grey)),

Tags:

Dart

Flutter