ZefyrThemeData.fallback constructor
ZefyrThemeData.fallback(
- BuildContext context
Implementation
factory ZefyrThemeData.fallback(BuildContext context) {
final themeData = Theme.of(context);
final defaultStyle = DefaultTextStyle.of(context);
final baseStyle = defaultStyle.style.copyWith(
fontSize: 16.0,
height: 1.3,
);
final baseSpacing = VerticalSpacing(top: 6.0, bottom: 10);
String? fontFamily;
switch (themeData.platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
fontFamily = 'Menlo';
break;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.windows:
case TargetPlatform.linux:
fontFamily = 'Roboto Mono';
break;
}
return ZefyrThemeData(
bold: TextStyle(fontWeight: FontWeight.bold),
italic: TextStyle(fontStyle: FontStyle.italic),
underline: TextStyle(decoration: TextDecoration.underline),
strikethrough: TextStyle(decoration: TextDecoration.lineThrough),
link: TextStyle(
color: themeData.colorScheme.secondary,
decoration: TextDecoration.underline,
),
paragraph: TextBlockTheme(
style: baseStyle,
spacing: baseSpacing,
// lineSpacing is not relevant for paragraphs since they consist of one line
),
heading1: TextBlockTheme(
style: defaultStyle.style.copyWith(
fontSize: 34.0,
color: defaultStyle.style.color!.withOpacity(0.70),
height: 1.15,
fontWeight: FontWeight.w300,
),
spacing: VerticalSpacing(top: 16.0, bottom: 0.0),
),
heading2: TextBlockTheme(
style: TextStyle(
fontSize: 24.0,
color: defaultStyle.style.color!.withOpacity(0.70),
height: 1.15,
fontWeight: FontWeight.normal,
),
spacing: VerticalSpacing(bottom: 0.0, top: 8.0),
),
heading3: TextBlockTheme(
style: TextStyle(
fontSize: 20.0,
color: defaultStyle.style.color!.withOpacity(0.70),
height: 1.25,
fontWeight: FontWeight.w500,
),
spacing: VerticalSpacing(bottom: 0.0, top: 8.0),
),
lists: TextBlockTheme(
style: baseStyle,
spacing: baseSpacing,
lineSpacing: VerticalSpacing(bottom: 6),
),
quote: TextBlockTheme(
style: TextStyle(color: baseStyle.color!.withOpacity(0.6)),
spacing: baseSpacing,
lineSpacing: VerticalSpacing(top: 6, bottom: 2),
decoration: BoxDecoration(
border: Border(
left: BorderSide(width: 4, color: Colors.grey.shade300),
),
),
),
code: TextBlockTheme(
style: TextStyle(
color: Colors.blue.shade900.withOpacity(0.9),
fontFamily: fontFamily,
fontSize: 13.0,
height: 1.15,
),
spacing: baseSpacing,
decoration: BoxDecoration(
color: Colors.grey.shade50,
borderRadius: BorderRadius.circular(2),
),
),
);
}