Commit dccccb9b authored by Adam Barth's avatar Adam Barth Committed by GitHub

Add fontFamily to ThemeData constructor (#9016)

Otherwise it's somewhat verbose to configure all the text themes.
parent f8cf576f
......@@ -93,6 +93,7 @@ class ThemeData {
Color indicatorColor,
Color hintColor,
Color errorColor,
String fontFamily,
TextTheme textTheme,
TextTheme primaryTextTheme,
TextTheme accentTextTheme,
......@@ -137,6 +138,11 @@ class ThemeData {
textTheme ??= isDark ? typography.white : typography.black;
primaryTextTheme ??= primaryIsDark ? typography.white : typography.black;
accentTextTheme ??= accentIsDark ? typography.white : typography.black;
if (fontFamily != null) {
textTheme = textTheme.apply(fontFamily: fontFamily);
primaryTextTheme = primaryTextTheme.apply(fontFamily: fontFamily);
accentTextTheme = accentTextTheme.apply(fontFamily: fontFamily);
}
return new ThemeData.raw(
brightness: brightness,
primaryColor: primaryColor,
......
......@@ -81,4 +81,12 @@ void main() {
expect(lightTheme.accentTextTheme.title.color, typography.black.title.color);
expect(darkTheme.accentTextTheme.title.color, typography.white.title.color);
});
test('Can control fontFamily', () {
final ThemeData themeData = new ThemeData(fontFamily: 'Ahem');
expect(themeData.textTheme.body2.fontFamily, equals('Ahem'));
expect(themeData.primaryTextTheme.title.fontFamily, equals('Ahem'));
expect(themeData.accentTextTheme.display4.fontFamily, equals('Ahem'));
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment