How to set textStyle of a Cupertino app in flutter

3,049

I've just run into this at the moment.

All I'm trying to do is colour text white, with general black backgrounds across the app (not font work).

The following has brought me some success:

return CupertinoApp(
  theme: new CupertinoThemeData(
    brightness: Brightness.dark,
    primaryColor: CupertinoColors.dark,
    barBackgroundColor: CupertinoColors.black,
    scaffoldBackgroundColor: CupertinoColors.black,
    textTheme: new CupertinoTextThemeData(
      primaryColor: CupertinoColors.white,
      brightness: Brightness.light,
      textStyle: TextStyle(color: CupertinoColors.white),
      // ... here I actually utilised all possible parameters in the constructor
      // as you can see in the link underneath
    ),
  ),
  // ...
)

Ref: CupertinoTextThemeData Constructor

I think you could extend my TextStyle(color: CupertinoColors.white) to apply fonts too. I intend to extract the TextStyle and ...ThemeData into separate classes to create a single place to edit them.

Hopefully this advances your position

Share:
3,049
M4trix Dev
Author by

M4trix Dev

Full-stack Flutter developer with history in Swift and Java, always looking forward to learning from this community

Updated on December 01, 2022

Comments

  • M4trix Dev
    M4trix Dev over 1 year

    I have a CupertinoApp and I would like to apply a custom TextStyle to all the screen/object of my app. For example I would lie to set a font family to all Text widget & Dialog widget and use that font across all my app. I was hoping to set it once in CupertinoThemeData or CupertinoTextThemeData but so far I did not have joy.

    Note: I am able to set style for each Text however I would like to set it once for all