Skip to content

Commit c154d1d

Browse files
[flutter_markdown] remove backgroundColor from code text theme to enable code selection highlight (flutter#7090)
fixes: flutter#150053 related to : flutter#96112
1 parent bc4dd46 commit c154d1d

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

packages/flutter_markdown/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.7.3+2
2+
3+
* Resolves an issue where code blocks in markdown were not highlighted during selection.
4+
15
## 0.7.3+1
26

37
* Fixes issue with table column alignments not being respected.

packages/flutter_markdown/lib/src/style_sheet.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class MarkdownStyleSheet {
104104
p: theme.textTheme.bodyMedium,
105105
pPadding: EdgeInsets.zero,
106106
code: theme.textTheme.bodyMedium!.copyWith(
107-
backgroundColor: theme.cardTheme.color ?? theme.cardColor,
107+
backgroundColor: theme.cardTheme.color,
108108
fontFamily: 'monospace',
109109
fontSize: theme.textTheme.bodyMedium!.fontSize! * 0.85,
110110
),
@@ -175,9 +175,6 @@ class MarkdownStyleSheet {
175175
p: theme.textTheme.textStyle,
176176
pPadding: EdgeInsets.zero,
177177
code: theme.textTheme.textStyle.copyWith(
178-
backgroundColor: theme.brightness == Brightness.dark
179-
? CupertinoColors.systemGrey6.darkColor
180-
: CupertinoColors.systemGrey6.color,
181178
fontFamily: 'monospace',
182179
fontSize: theme.textTheme.textStyle.fontSize! * 0.85,
183180
),
@@ -284,7 +281,7 @@ class MarkdownStyleSheet {
284281
p: theme.textTheme.bodyMedium,
285282
pPadding: EdgeInsets.zero,
286283
code: theme.textTheme.bodyMedium!.copyWith(
287-
backgroundColor: theme.cardTheme.color ?? theme.cardColor,
284+
backgroundColor: theme.cardTheme.color,
288285
fontFamily: 'monospace',
289286
fontSize: theme.textTheme.bodyMedium!.fontSize! * 0.85,
290287
),

packages/flutter_markdown/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A Markdown renderer for Flutter. Create rich text output,
44
formatted with simple Markdown tags.
55
repository: https://github.com/flutter/packages/tree/main/packages/flutter_markdown
66
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_markdown%22
7-
version: 0.7.3+1
7+
version: 0.7.3+2
88

99
environment:
1010
sdk: ^3.3.0

packages/flutter_markdown/test/style_sheet_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ void defineTests() {
6262
expect(
6363
style.code!.fontSize, cTheme.textTheme.textStyle.fontSize! * 0.85);
6464
expect(style.code!.fontFamily, 'monospace');
65-
expect(
66-
style.code!.backgroundColor, CupertinoColors.systemGrey6.darkColor);
6765

6866
// H1
6967
expect(style.h1!.color, cTheme.textTheme.textStyle.color);
@@ -152,7 +150,7 @@ void defineTests() {
152150
expect(
153151
style.code!.fontSize, theme.textTheme.bodyMedium!.fontSize! * 0.85);
154152
expect(style.code!.fontFamily, 'monospace');
155-
expect(style.code!.backgroundColor, theme.cardColor);
153+
expect(style.code!.backgroundColor, theme.cardTheme.color);
156154

157155
// H1
158156
expect(style.h1, theme.textTheme.headlineSmall);

0 commit comments

Comments
 (0)