I finally found out.
I set the fontFamily
as follows.
@override
Widget build(BuildContext context) {
return GetMaterialApp(
theme: ThemeData(
fontFamily: 'YourAwesomeFontFamily',
),
...,
);
}
And I wanted to change the textStyle
of the AppBar
as well, so I set it as follows.
child: Scaffold(
appBar: AppBar(
title: const Text(
'Awesome Title'
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
),
),
),
...,
),
wow
AppBar
‘s fontFamily
had to be set separately.
style: TextStyle(
fontFamily: 'YourAwesomeFontFamily', // <- this must go in
...,
),
Why is this?
Looking for it, is the TabBar
like that too?
I set the labelStyle
because I wanted to make the Tab
‘s font fancy, but the fontFamily
was missing.
child: TabBar(
labelStyles: TextStyle(
fontFamily: 'YourAwesomeFontFamily', // <- this must go in
color: Colors.red,
),
...,
),
But what? Just Text
widget comes out with the fontFamily
set in ThemeData
even if there is no fontFamily
.
Text(
'Applied fontFamily',
style(
// here is no fontFamily
color: Colors.red,
),
),
So it was only now that I found out.
I am very confused right now.
I’d appreciate it if you could give me a hint as to why this is.
2
Answers
I found the reason.
Text
widget'sTextStyle
hasinherit
property.If
inherit
isfalse
, it'll overrideTextStyle
, but default value istrue
.text.dart
But
AppBar
's theme is applied differently, which always override.app_bar_theme.dart
Here is the hint you need:
happy coding…