Skip to content

[flutter_markdown] remove backgroundColor from code text theme to enable code selection highlight #7090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
4 changes: 4 additions & 0 deletions packages/flutter_markdown/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.7.3+2

* Resolves an issue where code blocks in markdown were not highlighted during selection.

## 0.7.3+1

* Fixes issue with table column alignments not being respected.
Expand Down
7 changes: 2 additions & 5 deletions packages/flutter_markdown/lib/src/style_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class MarkdownStyleSheet {
p: theme.textTheme.bodyMedium,
pPadding: EdgeInsets.zero,
code: theme.textTheme.bodyMedium!.copyWith(
backgroundColor: theme.cardTheme.color ?? theme.cardColor,
backgroundColor: theme.cardTheme.color,
fontFamily: 'monospace',
fontSize: theme.textTheme.bodyMedium!.fontSize! * 0.85,
),
Expand Down Expand Up @@ -175,9 +175,6 @@ class MarkdownStyleSheet {
p: theme.textTheme.textStyle,
pPadding: EdgeInsets.zero,
code: theme.textTheme.textStyle.copyWith(
backgroundColor: theme.brightness == Brightness.dark
? CupertinoColors.systemGrey6.darkColor
: CupertinoColors.systemGrey6.color,
fontFamily: 'monospace',
fontSize: theme.textTheme.textStyle.fontSize! * 0.85,
),
Expand Down Expand Up @@ -284,7 +281,7 @@ class MarkdownStyleSheet {
p: theme.textTheme.bodyMedium,
pPadding: EdgeInsets.zero,
code: theme.textTheme.bodyMedium!.copyWith(
backgroundColor: theme.cardTheme.color ?? theme.cardColor,
backgroundColor: theme.cardTheme.color,
fontFamily: 'monospace',
fontSize: theme.textTheme.bodyMedium!.fontSize! * 0.85,
),
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_markdown/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A Markdown renderer for Flutter. Create rich text output,
formatted with simple Markdown tags.
repository: https://github.com/flutter/packages/tree/main/packages/flutter_markdown
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_markdown%22
version: 0.7.3+1
version: 0.7.3+2

environment:
sdk: ^3.3.0
Expand Down
4 changes: 1 addition & 3 deletions packages/flutter_markdown/test/style_sheet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ void defineTests() {
expect(
style.code!.fontSize, cTheme.textTheme.textStyle.fontSize! * 0.85);
expect(style.code!.fontFamily, 'monospace');
expect(
style.code!.backgroundColor, CupertinoColors.systemGrey6.darkColor);

// H1
expect(style.h1!.color, cTheme.textTheme.textStyle.color);
Expand Down Expand Up @@ -152,7 +150,7 @@ void defineTests() {
expect(
style.code!.fontSize, theme.textTheme.bodyMedium!.fontSize! * 0.85);
expect(style.code!.fontFamily, 'monospace');
expect(style.code!.backgroundColor, theme.cardColor);
expect(style.code!.backgroundColor, theme.cardTheme.color);

// H1
expect(style.h1, theme.textTheme.headlineSmall);
Expand Down