0

Is there a straight forward way to change the font family to a widget and all its children?

my thought was to have an inherited widget and store the font family and call it to get that when creating every text widgets and set its style, but I prefer a simpler way.

1 Answers1

2

You can wrap the widget whose descendants you want to change (e.g. MyWidget()) in a Theme Widget. For example:

Container(
 child: Theme(
          data: Theme.of(context).copyWith(
              textTheme: TextTheme(<your changes here>),
              ),
          child: MyWidget()
        )
)
Wessel
  • 617
  • 4
  • 13