Skip to content
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

'Cannot add to an unmodifiable list' seen when running the flutter_markdown tests #480

Closed
devoncarew opened this issue Oct 31, 2022 · 1 comment · Fixed by flutter/packages#2758

Comments

@devoncarew
Copy link
Member

I bisected a recent roll failure to d72ae07 ; here is the test failure:

flutter_markdown/test/custom_syntax_test.dart: Custom Syntax link for wikistyle              
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following UnsupportedError was thrown building Directionality(textDirection: ltr):
Unsupported operation: Cannot add to an unmodifiable list

The relevant error-causing widget was:
  Directionality
  Directionality:file:///Users/devoncarew/projects/flutter/packages/packages/flutter_markdown/test/utils.dart:164:10

When the exception was thrown, this was the stack:
#0      UnmodifiableListMixin.add (dart:_internal/list.dart:114:5)
#1      WikilinkSyntax.onMatch (file:///Users/devoncarew/projects/flutter/packages/packages/flutter_markdown/test/custom_syntax_test.dart:165:18)
#2      InlineSyntax.tryMatch (package:markdown/src/inline_syntaxes/inline_syntax.dart:49:9)
#3      InlineParser.parse.<anonymous closure> (package:markdown/src/inline_parser.dart:119:43)
#4      ListMixin.any (dart:collection/list.dart:149:15)
#5      InlineParser.parse (package:markdown/src/inline_parser.dart:119:20)
#6      Document.parseInline (package:markdown/src/document.dart:76:67)
#7      Document._parseInlineContent (package:markdown/src/document.dart:82:29)
#8      Document._parseInlineContent (package:markdown/src/document.dart:87:9)
#9      Document.parseLines (package:markdown/src/document.dart:71:5)
#10     _MarkdownWidgetState._parseMarkdown (package:flutter_markdown/src/widget.dart:320:45)
#11     _MarkdownWidgetState.didChangeDependencies (package:flutter_markdown/src/widget.dart:284:5)
#12     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5110:11)
#13     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4935:5)
...     Normal element mounting (7 frames)
#20     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3944:16)
#21     Element.updateChild (package:flutter/src/widgets/framework.dart:3667:20)
#22     RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1180:16)
#23     RenderObjectToWidgetElement.update (package:flutter/src/widgets/binding.dart:1157:5)
#24     RenderObjectToWidgetElement.performRebuild (package:flutter/src/widgets/binding.dart:1171:7)
#25     Element.rebuild (package:flutter/src/widgets/framework.dart:4681:5)
#26     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2734:19)
#27     AutomatedTestWidgetsFlutterBinding.drawFrame (package:flutter_test/src/binding.dart:1333:19)
#28     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:381:5)
#29     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1275:15)
#30     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1204:9)
#31     AutomatedTestWidgetsFlutterBinding.pump.<anonymous closure> (package:flutter_test/src/binding.dart:1182:9)
#34     TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:71:41)
#35     AutomatedTestWidgetsFlutterBinding.pump (package:flutter_test/src/binding.dart:1168:27)
#36     WidgetTester.pumpWidget.<anonymous closure> (package:flutter_test/src/widget_tester.dart:558:22)
#39     TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:71:41)
#40     WidgetTester.pumpWidget (package:flutter_test/src/widget_tester.dart:555:27)
#41     defineTests.<anonymous closure>.<anonymous closure> (file:///Users/devoncarew/projects/flutter/packages/packages/flutter_markdown/test/custom_syntax_test.dart:41:22)
#42     testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:171:29)
<asynchronous suspension>
<asynchronous suspension>
(elided 5 frames from dart:async and package:stack_trace)

════════════════════════════════════════════════════════════════════════════════════════════════════
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following StateError was thrown running a test:
Bad state: No element

When the exception was thrown, this was the stack:
#0      Iterable.single (dart:core/iterable.dart:654:25)
#1      WidgetController.widget (package:flutter_test/src/controller.dart:284:30)
#2      defineTests.<anonymous closure>.<anonymous closure> (file:///Users/devoncarew/projects/flutter/packages/packages/flutter_markdown/test/custom_syntax_test.dart:54:44)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)
@srawlins
Copy link
Member

Yeah we can back out the specific diff

srawlins added a commit to flutter/packages that referenced this issue Nov 1, 2022
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 dart-lang/markdown#480
srawlins added a commit to flutter/packages that referenced this issue Nov 2, 2022
…ction (#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 dart-lang/markdown#480
percula pushed a commit to percula/packages that referenced this issue Nov 17, 2022
…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 dart-lang/markdown#480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants