-
Notifications
You must be signed in to change notification settings - Fork 281
Open
Labels
area_markdownf:charityUnpaid workUnpaid worktime:2type_bugSomething isn't workingSomething isn't working
Description
Package Version
Latest main
To Reproduce
Steps to reproduce the behavior:
- Add attribution to part of text node, for example bold
- Insert placeholder after the bolded part
Minimal Reproduction Code
Reproducible by adding inlineWidgetBuilder to SuperEditor in example_editor.dart in example app.
Minimal, Runnable Code Sample
Widget? inlineWidgetBuilder(
BuildContext context, TextStyle textStyle, Object placeholder) {
if (placeholder is! ExamplePlaceholder) {
return null;
}
return LineHeight(
style: textStyle,
child: Container(
color: Colors.red,
padding: EdgeInsets.symmetric(horizontal: 8),
child: Text(
'placeholder',
style: textStyle,
)));
}
class ExamplePlaceholder {
const ExamplePlaceholder();
}
Add a button somewhere to insert the placeholder:
TextButton(
onPressed: () {
_docEditor.execute([
InsertInlinePlaceholderAtCaretRequest(
ExamplePlaceholder())
]);
},
child: Text('add placeholder'));
);
Actual behavior
The editor crashes with the following exception:
════════ Exception caught by gesture ═══════════════════════════════════════════
The following _TypeError was thrown while handling a gesture:
type 'ExamplePlaceholder' is not a subtype of type 'String' in type cast
When the exception was thrown, this was the stack:
#0 _UpstreamInlineMarkdownParser._tryCreateLinkRun (package:super_editor_markdown/src/markdown_inline_upstream_plugin.dart:320:62)
#1 _UpstreamInlineMarkdownParser.findMarkdown (package:super_editor_markdown/src/markdown_inline_upstream_plugin.dart:251:21)
#2 MarkdownInlineUpstreamSyntaxReaction._applyInlineMarkdownBeforeCaret (package:super_editor_markdown/src/markdown_inline_upstream_plugin.dart:151:38)
#3 MarkdownInlineUpstreamSyntaxReaction.react (package:super_editor_markdown/src/markdown_inline_upstream_plugin.dart:106:26)
#4 Editor._reactToChanges (package:super_editor/src/core/editor.dart:357:16)
#5 Editor.endTransaction (package:super_editor/src/core/editor.dart:222:5)
#6 Editor.execute (package:super_editor/src/core/editor.dart:283:7)
#7 _ExampleEditorState._buildDebugVisualsToggle.<anonymous closure>.<anonymous closure> (package:example/demos/example_editor/example_editor.dart:350:22)
#8 State.setState (package:flutter/src/widgets/framework.dart:1207:30)
#9 _ExampleEditorState._buildDebugVisualsToggle.<anonymous closure> (package:example/demos/example_editor/example_editor.dart:349:9)
#10 _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1185:21)
#11 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:357:24)
#12 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:653:11)
#13 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:307:5)
#14 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:240:7)
#15 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:718:9)
#16 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:97:12)
#17 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
#18 _LinkedHashMapMixin.forEach (dart:_compact_hash:763:13)
#19 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
#20 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:131:7)
#21 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:530:19)
#22 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:499:22)
#23 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:460:11)
#24 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:437:7)
#25 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:394:5)
#26 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:341:7)
#27 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:308:9)
#28 _invoke1 (dart:ui/hooks.dart:332:13)
#29 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:451:7)
#30 _dispatchPointerDataPacket (dart:ui/hooks.dart:267:31)
Expected behavior
The placeholder should be inserted
Platform
Any platform
Flutter version
Flutter 3.29
Metadata
Metadata
Assignees
Labels
area_markdownf:charityUnpaid workUnpaid worktime:2type_bugSomething isn't workingSomething isn't working