Skip to content

Commit e586d2f

Browse files
committed
[flutter_markdown] fix for latest pkg:markdown part 2
1 parent 4cb9b29 commit e586d2f

File tree

2 files changed

+51
-11
lines changed

2 files changed

+51
-11
lines changed

packages/flutter_markdown/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+
77
version: 0.6.13
88

99
environment:
10-
sdk: ">=2.12.0 <3.0.0"
11-
flutter: ">=3.0.0"
10+
sdk: '>=2.12.0 <3.0.0'
11+
flutter: '>=3.0.0'
1212

1313
dependencies:
1414
flutter:

packages/flutter_markdown/test/link_test.dart

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ import 'package:flutter/gestures.dart';
66
import 'package:flutter/widgets.dart';
77
import 'package:flutter_markdown/flutter_markdown.dart';
88
import 'package:flutter_test/flutter_test.dart';
9+
import 'package:markdown/markdown.dart' as md show version;
910
import 'utils.dart';
1011

12+
// TODO(Zhiguang): delete this once the min version of pkg:markdown is updated
13+
final bool _newMarkdown = md.version.compareTo('6.0.1') > 0;
14+
1115
void main() => defineTests();
1216

1317
void defineTests() {
@@ -628,7 +632,13 @@ void defineTests() {
628632
);
629633

630634
expectValidLink('link');
631-
expectLinkTap(linkTapResults, const MarkdownLink('link', 'foo\bar'));
635+
if (!_newMarkdown) {
636+
// For pkg:markdown <= v6.0.1
637+
expectLinkTap(linkTapResults, const MarkdownLink('link', 'foo\bar'));
638+
} else {
639+
// For pkg:markdown > v6.0.1
640+
expectLinkTap(linkTapResults, const MarkdownLink('link', 'foo%08ar'));
641+
}
632642
},
633643
);
634644

@@ -649,8 +659,15 @@ void defineTests() {
649659
);
650660

651661
expectValidLink('link');
652-
expectLinkTap(
653-
linkTapResults, const MarkdownLink('link', 'foo%20b&auml;'));
662+
if (!_newMarkdown) {
663+
// For pkg:markdown <= v6.0.1
664+
expectLinkTap(
665+
linkTapResults, const MarkdownLink('link', 'foo%20b&auml;'));
666+
} else {
667+
// For pkg:markdown > v6.0.1
668+
expectLinkTap(
669+
linkTapResults, const MarkdownLink('link', 'foo%20b%C3%A4'));
670+
}
654671
},
655672
);
656673

@@ -759,8 +776,15 @@ void defineTests() {
759776
);
760777

761778
expectValidLink('link');
762-
expectLinkTap(linkTapResults,
763-
const MarkdownLink('link', '/url', 'title %22&quot;'));
779+
if (!_newMarkdown) {
780+
// For pkg:markdown <= v6.0.1
781+
expectLinkTap(linkTapResults,
782+
const MarkdownLink('link', '/url', 'title %22&quot;'));
783+
} else {
784+
// For pkg:markdown > v6.0.1
785+
expectLinkTap(linkTapResults,
786+
const MarkdownLink('link', '/url', 'title &quot;&quot;'));
787+
}
764788
},
765789
);
766790

@@ -781,8 +805,15 @@ void defineTests() {
781805
);
782806

783807
expectValidLink('link');
784-
expectLinkTap(linkTapResults,
785-
const MarkdownLink('link', '/url\u{C2A0}%22title%22'));
808+
if (!_newMarkdown) {
809+
// For pkg:markdown <= v6.0.1
810+
expectLinkTap(linkTapResults,
811+
const MarkdownLink('link', '/url\u{C2A0}%22title%22'));
812+
} else {
813+
// For pkg:markdown > v6.0.1
814+
expectLinkTap(linkTapResults,
815+
const MarkdownLink('link', '/url%EC%8A%A0%22title%22'));
816+
}
786817
},
787818
);
788819

@@ -825,8 +856,17 @@ void defineTests() {
825856
);
826857

827858
expectValidLink('link');
828-
expectLinkTap(linkTapResults,
829-
const MarkdownLink('link', '/url', 'title %22and%22 title'));
859+
if (!_newMarkdown) {
860+
// For pkg:markdown <= v6.0.1
861+
expectLinkTap(linkTapResults,
862+
const MarkdownLink('link', '/url', 'title %22and%22 title'));
863+
} else {
864+
// For pkg:markdown > v6.0.1
865+
expectLinkTap(
866+
linkTapResults,
867+
const MarkdownLink('link', '/url', 'title &quot;and&quot; title'),
868+
);
869+
}
830870
},
831871
);
832872

0 commit comments

Comments
 (0)