resolve method
Resolves unset fields against the ambient ThemeData.
Implementation
PrismMarkdownStyle resolve(BuildContext context) {
final theme = Theme.of(context);
final base = theme.textTheme.bodyMedium ?? const TextStyle(fontSize: 14);
final codeColor = theme.colorScheme.surfaceContainerHighest;
final headings = <TextStyle>[
for (var i = 0; i < 6; i++)
TextStyle(
inherit: false,
color: base.color,
fontFamily: base.fontFamily,
fontSize: base.fontSize! * (1.75 - 0.13 * i),
fontWeight: FontWeight.w700,
height: 1.25,
),
];
return PrismMarkdownStyle(
textStyle: textStyle ?? base,
headingStyle: headingStyle ?? headings,
codeStyle:
codeStyle ??
(base.copyWith(
fontFamily: 'monospace',
fontSize: base.fontSize! * 0.9,
background: Paint()..color = codeColor,
)),
codeBackground: codeBackground ?? codeColor,
codeblockBackground: codeblockBackground ?? codeColor,
codeblockPadding: codeblockPadding ?? const EdgeInsets.all(12),
blockquoteDecoration:
blockquoteDecoration ??
BoxDecoration(
border: Border(
left: BorderSide(color: theme.dividerColor, width: 4),
),
),
blockquotePadding:
blockquotePadding ??
const EdgeInsets.only(left: 12, top: 4, bottom: 4),
tableBorder:
tableBorder ?? TableBorder.all(color: theme.dividerColor, width: 1),
tableHeaderBackground:
tableHeaderBackground ?? theme.colorScheme.surfaceContainerHighest,
linkStyle:
linkStyle ??
base.copyWith(
color: theme.colorScheme.primary,
decoration: TextDecoration.underline,
),
listPadding: listPadding ?? EdgeInsets.zero,
horizontalRuleThickness: horizontalRuleThickness ?? 1,
horizontalRuleColor: horizontalRuleColor ?? theme.dividerColor,
);
}