Skip to content

Commit

Permalink
[flutter_markdown] Do not modify children of an Element after constru…
Browse files Browse the repository at this point in the history
…ction (flutter#2758)

Do not modify children of a markdown Element after construction

The children list of an Element became unmodifiable in dart-lang/markdown#463, so this just changes flutter_markdown to not modify the children, in a test.

Fixes https://github.com/dart-lang/markdown/issues/480
  • Loading branch information
srawlins authored Nov 2, 2022
1 parent 4b37722 commit 3c83881
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/flutter_markdown/test/custom_syntax_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ class WikilinkSyntax extends md.InlineSyntax {

@override
bool onMatch(md.InlineParser parser, Match match) {
final md.Element el = md.Element.withTag('wikilink');
el.attributes['href'] = match[1]!.replaceAll(' ', '_');
el.children!.add(md.Element.text('span', match[1]!));
final String link = match[1]!;
final md.Element el =
md.Element('wikilink', <md.Element>[md.Element.text('span', link)])
..attributes['href'] = link.replaceAll(' ', '_');

parser.addNode(el);
return true;
Expand Down

0 comments on commit 3c83881

Please sign in to comment.