andyduke / styled_text_package

Text widget with formatted text using tags. Makes it easier to use formatted text in multilingual applications.
https://pub.dev/packages/styled_text
BSD 3-Clause "New" or "Revised" License
75 stars 48 forks source link

A semantic error occurs when used with `CheckboxListTile`. #68

Closed wikiminia closed 1 year ago

wikiminia commented 1 year ago

Used version: styled_text: ^7.0.0

Widget:

CheckboxListTile(
  value: true,
  onChanged: (check) {},
  title: StyledText(
    text:
        'Text with <link href="https://flutter.dev">link</link> inside.',
    tags: {
      'link': StyledTextActionTag(
        (String? text, Map<String?, String?> attrs) {
          String? link = attrs['href'];
          print('The "$link" link is tapped.');
        },
        style: TextStyle(decoration: TextDecoration.underline),
      ),
    },
  ),
)
══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during a scheduler callback:
'package:flutter/src/semantics/semantics.dart': Failed assertion: line 3105 pos 16: 'node.parent ==
null || !node.parent!.isPartOfNodeMerging || node.isMergedIntoParent': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially
more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack:
#2      SemanticsOwner.sendSemanticsUpdate (package:flutter/src/semantics/semantics.dart:3105:16)
#3      PipelineOwner.flushSemantics (package:flutter/src/rendering/object.dart:1246:24)
#4      RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:521:21)
#5      WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:865:13)
#6      RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:381:5)
#7      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1289:15)
#8      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1218:9)
#9      SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1076:5)
#10     _invoke (dart:ui/hooks.dart:145:13)
#11     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:338:5)
#12     _drawFrame (dart:ui/hooks.dart:112:31)
(elided 2 frames from class _AssertionError)
════════════════════════════════════════════════════════════════════════════════════════════════════

A semantic error occurs as shown above.

When I use other StyledTextTags or StyledTextIconTags, I don't have any problems, but when I use only StyledTextActionTag and matched tags exist, I get an error immediately on debug mode on iOS simulator.

wikiminia commented 1 year ago

Oh, maybe it is like this issue: https://github.com/flutter/flutter/issues/31437 I wanted to use StyledText with CheckboxListTile. Maybe I should use Checkbox widget.