NZMarkdownStyle.defaultStyle constructor
NZMarkdownStyle.defaultStyle(
- BuildContext context
默认样式工厂方法,根据当前的 BuildContext 自动生成适配主题的样式。
Implementation
factory NZMarkdownStyle.defaultStyle(BuildContext context) {
final theme = Theme.of(context);
return NZMarkdownStyle(
h1: theme.textTheme.headlineLarge?.copyWith(
fontWeight: FontWeight.bold,
color: theme.colorScheme.onSurface,
fontSize: 28,
),
h2: theme.textTheme.headlineMedium?.copyWith(
fontWeight: FontWeight.bold,
color: theme.colorScheme.onSurface,
fontSize: 24,
),
h3: theme.textTheme.headlineSmall?.copyWith(
fontWeight: FontWeight.bold,
color: theme.colorScheme.onSurface,
fontSize: 20,
),
p: theme.textTheme.bodyLarge?.copyWith(
color: theme.colorScheme.onSurface.withValues(alpha: 0.8),
height: 1.6,
),
code: TextStyle(
fontFamily: 'monospace',
fontSize: 14,
color: theme.colorScheme.onSurface,
),
codeBackground: theme.colorScheme.surfaceContainerHighest.withValues(
alpha: 0.3,
),
blockquote: theme.textTheme.bodyMedium?.copyWith(
fontStyle: FontStyle.italic,
color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
),
blockquoteBorderColor: theme.colorScheme.primary.withValues(alpha: 0.5),
padding: const EdgeInsets.all(16),
);
}