|
3 | 3 | // found in the LICENSE file. |
4 | 4 |
|
5 | 5 | import 'package:flutter/material.dart'; |
6 | | -import 'package:flutter_markdown/flutter_markdown.dart'; |
| 6 | +import 'package:gpt_markdown/gpt_markdown.dart'; |
7 | 7 |
|
8 | | -MarkdownStyleSheet getMarkdownStyleSheet(BuildContext context) { |
9 | | - final theme = Theme.of(context); |
10 | | - return MarkdownStyleSheet.fromTheme( |
11 | | - theme, |
12 | | - ).copyWith(p: theme.textTheme.bodyMedium); |
| 8 | +class MarkdownWidget extends StatelessWidget { |
| 9 | + const MarkdownWidget({super.key, required this.text}); |
| 10 | + |
| 11 | + final String text; |
| 12 | + |
| 13 | + @override |
| 14 | + Widget build(BuildContext context) { |
| 15 | + final theme = Theme.of(context); |
| 16 | + final textTheme = theme.textTheme; |
| 17 | + return GptMarkdownTheme( |
| 18 | + gptThemeData: GptMarkdownThemeData( |
| 19 | + brightness: theme.brightness, |
| 20 | + highlightColor: theme.colorScheme.onSurfaceVariant.withAlpha(50), |
| 21 | + h1: textTheme.headlineLarge, |
| 22 | + h2: textTheme.headlineMedium, |
| 23 | + h3: textTheme.headlineSmall, |
| 24 | + h4: textTheme.titleLarge, |
| 25 | + h5: textTheme.titleMedium, |
| 26 | + h6: textTheme.titleSmall, |
| 27 | + hrLineThickness: 1, |
| 28 | + hrLineColor: theme.colorScheme.outline, |
| 29 | + linkColor: Colors.blue, |
| 30 | + linkHoverColor: Colors.red, |
| 31 | + ), |
| 32 | + child: GptMarkdown(text), |
| 33 | + ); |
| 34 | + } |
13 | 35 | } |
0 commit comments