Search code examples
flutterflutter-text

How to set default font color in flutter?


I want to set the default font colour for the flutter app globally. I tried

ThemeData(
    primarySwatch: Colors.blue,
    fontFamily: 'Gilroy',
    textTheme: TextTheme(
      bodyText1: TextStyle(),
      bodyText2: TextStyle(),
    ).apply(
      bodyColor: const Color(0xff22215B),
      displayColor:  const Color(0xff22215B),
    ),
  ),

Some text is coloured. but Text in Appbar is not applied automatically.


Solution

  • Apply this

    ThemeData(
            appBarTheme: AppBarTheme(
              textTheme: Theme.of(context).textTheme.apply(
                    bodyColor: const Color(0xff22215B),
                    displayColor: const Color(0xff22215B),
                  ),
            ),
            textTheme: Theme.of(context).textTheme.apply(
                  bodyColor: const Color(0xff22215B),
                  displayColor: const Color(0xff22215B),
                ),
          )