From 979e91378b2488f5db82b7e4b1bb833fcb340892 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Sun, 8 Nov 2020 17:21:02 +0800 Subject: [PATCH] fix: markdown webview dark mode --- lib/widgets/markdown_view.dart | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/widgets/markdown_view.dart b/lib/widgets/markdown_view.dart index de5a21c2..bef5584f 100644 --- a/lib/widgets/markdown_view.dart +++ b/lib/widgets/markdown_view.dart @@ -63,7 +63,21 @@ class MarkdownWebView extends StatelessWidget { @override Widget build(BuildContext context) { final theme = Provider.of(context); - return HtmlView(html, cssText: theme.markdownCss); + var css = theme.markdownCss; + if (theme.brightness == Brightness.dark) { + css += ''' +html { + background-color: #000; +} +.markdown-body { + filter:invert(100%); +} +.markdown-body img { + filter:invert(100%); +}' +'''; + } + return HtmlView(html, cssText: css); } }