Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package/lib/src/controls/highlight_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ class HighlightView extends StatelessWidget {
}

static const _rootKey = 'root';
static const _defaultFontColor = Color(0xff000000);
static const _defaultBackgroundColor = Color(0xffffffff);

// TODO: dart:io is not available at web platform currently
// See: https://github.com/flutter/flutter/issues/39998
Expand All @@ -86,14 +84,16 @@ class HighlightView extends StatelessWidget {
Widget build(BuildContext context) {
var style = TextStyle(
fontFamily: _defaultFontFamily,
color: theme[_rootKey]?.color ?? _defaultFontColor,
color: theme[_rootKey]?.color ??
Theme.of(context).colorScheme.onSurfaceVariant,
);
if (textStyle != null) {
style = style.merge(textStyle);
}

var d = BoxDecoration(
color: theme[_rootKey]?.backgroundColor ?? _defaultBackgroundColor);
color: theme[_rootKey]?.backgroundColor ??
Theme.of(context).colorScheme.surfaceVariant);

if (decoration != null) {
d = d.copyWith(borderRadius: (decoration as BoxDecoration).borderRadius);
Expand Down
7 changes: 4 additions & 3 deletions package/lib/src/controls/markdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MarkdownControl extends StatelessWidget {
final ws = FletAppServices.of(context).ws;

var value = control.attrString("value", "")!;
var codeTheme = control.attrString("codeTheme", "github")!;
var codeTheme = control.attrString("codeTheme", "")!;
md.ExtensionSet extensionSet = md.ExtensionSet.none;
switch (control.attrString("extensionSet", "")!.toLowerCase()) {
case "commonmark":
Expand Down Expand Up @@ -60,7 +60,8 @@ class MarkdownControl extends StatelessWidget {
imageDirectory: getBaseUri(pageUri!).toString(),
extensionSet: extensionSet,
builders: {
'code': CodeElementBuilder(codeTheme, mdStyleSheet),
'code':
CodeElementBuilder(codeTheme.toLowerCase(), mdStyleSheet),
},
styleSheet: mdStyleSheet,
onTapLink: (String text, String? href, String title) {
Expand Down Expand Up @@ -105,7 +106,7 @@ class CodeElementBuilder extends MarkdownElementBuilder {

// Specify highlight theme
// All available themes are listed in `themes` folder
theme: themeMap[codeTheme] ?? themeMap["github"]!,
theme: themeMap[codeTheme] ?? {},

// Specify padding
padding: mdStyleSheet.codeblockPadding,
Expand Down