提问人:Jimmy Donovan 提问时间:10/7/2023 最后编辑:Wiktor StribiżewJimmy Donovan 更新时间:10/8/2023 访问量:30
Flutter rich_text_controller 包正回溯抛出错误错误状态:无元素
Flutter rich_text_controller package positive lookbehinds throws error bad state: no element
问:
我注意到当我尝试使用正面回溯时,rich_text_editor flutter 包会持续抛出相同的错误。似乎无论创建什么模式以及用户条目的内容是什么,只要在正则表达式的 lookbehdind 部分之后输入字符,它就会失败。
import 'package:rich_text_controller/rich_text_controller.dart';
static final LinkedHashMap<RegExp, TextStyle> patternUser =
LinkedHashMap.of({
RegExp(r"\B@bold\b"): TextStyle(color: Colors.amber, FontStyle.italic),
RegExp(r"(?<=\B@bold\b) [a-zA-Z0-9]+", multiLine: true): TextStyle(color:
Colors.grey, fontWeight:FontWeight.bold),
});
RichTextController _controller = RichTextController(
patternMatchMap: patternUser,
onMatch: (List<String> match) { },
);
这将在测试短语上失败。其他格式工作正常,似乎只有前瞻和后视才会引起问题。"test message @bold x"
完整的错误报告如下:
======== Exception caught by animation library
The following assertion was thrown while notifying listeners for AnimationController:
A _CaretPainter was used after being disposed.
Once you have called dispose() on a _CaretPainter, it can no longer be used.
When the exception was thrown, this was the stack:
#0 ChangeNotifier.debugAssertNotDisposed.<anonymous closure> (package:flutter/src/foundation/change_notifier.dart:179:9)
#1 ChangeNotifier.debugAssertNotDisposed (package:flutter/src/foundation/change_notifier.dart:186:6)
#2 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:382:27)
#3 _CaretPainter.caretColor= (package:flutter/src/rendering/editable.dart:2784:5)
#4 RenderEditable.cursorColor= (package:flutter/src/rendering/editable.dart:865:19)
#5 EditableTextState._onCursorColorTick (package:flutter/src/widgets/editable_text.dart:3708:20)
#6 AnimationLocalListenersMixin.notifyListeners (package:flutter/src/animation/listener_helpers.dart:161:19)
#7 AnimationController._tick (package:flutter/src/animation/animation_controller.dart:830:5)
#8 Ticker._tick (package:flutter/src/scheduler/ticker.dart:249:12)
#9 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1297:15)
#10 SchedulerBinding.handleBeginFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:1149:11)
#11 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#12 SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:1147:17)
#13 SchedulerBinding._handleBeginFrame (package:flutter/src/scheduler/binding.dart:1064:5)
#14 _invoke1 (dart:ui/hooks.dart:186:13)
#15 PlatformDispatcher._beginFrame (dart:ui/platform_dispatcher.dart:379:5)
#16 _beginFrame (dart:ui/hooks.dart:129:31)
The AnimationController notifying listeners was: AnimationController#e3468(▶ 0.000)
==============================
======== Exception caught by widgets library ================================
The following StateError was thrown building Scrollable-[GlobalKey#1fb15](axisDirection: down, physics: null, restorationId: "editable", dependencies: [MediaQuery, UnmanagedRestorationScope, _InheritedTheme, _LocalizationsScope-[GlobalKey#86640]], state: ScrollableState#2bdc3(position: ScrollPositionWithSingleContext#2caa5(offset: 0.0, range: 0.0..0.0, viewport: 21.0, ScrollableState, BouncingScrollPhysics -> RangeMaintainingScrollPhysics -> BouncingScrollPhysics -> RangeMaintainingScrollPhysics, IdleScrollActivity#af1d4, ScrollDirection.idle), effective physics: BouncingScrollPhysics -> RangeMaintainingScrollPhysics -> BouncingScrollPhysics -> RangeMaintainingScrollPhysics)):
Bad state: No element
The relevant error-causing widget was:
TextFormField TextFormField:file:<MyFilePath.dart>:44:18
When the exception was thrown, this was the stack:
#0 Iterable.firstWhere (dart:core/iterable.dart:700:5)
#1 RichTextController.buildTextSpan.<anonymous closure> (package:rich_text_controller/rich_text_controller.dart:139:52)
#2 _StringBase.splitMapJoin (dart:core-patch/string_patch.dart:818:27)
#3 RichTextController.buildTextSpan (package:rich_text_controller/rich_text_controller.dart:115:10)
#4 EditableTextState.buildTextSpan (package:flutter/src/widgets/editable_text.dart:4789:30)
#5 EditableTextState.build.<anonymous closure> (package:flutter/src/widgets/editable_text.dart:4674:41)
#6 ScrollableState.build (package:flutter/src/widgets/scrollable.dart:966:44)
#7 StatefulElement.build (package:flutter/src/widgets/framework.dart:5409:27)
#8 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5297:15)
#9 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
#10 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#11 StatefulElement.update (package:flutter/src/widgets/framework.dart:5485:5)
#12 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#13 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#14 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#15 ProxyElement.update (package:flutter/src/widgets/framework.dart:5628:5)
#16 _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:107:11)
#17 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#18 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#19 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
#20 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#21 StatefulElement.update (package:flutter/src/widgets/framework.dart:5485:5)
#22 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#23 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#24 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#25 ProxyElement.update (package:flutter/src/widgets/framework.dart:5628:5)
#26 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#27 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#28 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
#29 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#30 StatefulElement.update (package:flutter/src/widgets/framework.dart:5485:5)
#31 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#32 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#33 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
#34 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#35 StatefulElement.update (package:flutter/src/widgets/framework.dart:5485:5)
#36 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#37 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#38 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#39 ProxyElement.update (package:flutter/src/widgets/framework.dart:5628:5)
#40 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#41 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#42 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
#43 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#44 StatefulElement.update (package:flutter/src/widgets/framework.dart:5485:5)
#45 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#46 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6441:14)
#47 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#48 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6441:14)
#49 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#50 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6441:14)
#51 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#52 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#53 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
#54 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#55 StatefulElement.update (package:flutter/src/widgets/framework.dart:5485:5)
#56 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#57 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#58 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#59 ProxyElement.update (package:flutter/src/widgets/framework.dart:5628:5)
#60 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#61 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6441:14)
#62 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#63 SlottedRenderObjectElement._updateChildren (package:flutter/src/widgets/slotted_render_object_widget.dart:295:33)
#64 SlottedRenderObjectElement.update (package:flutter/src/widgets/slotted_render_object_widget.dart:256:5)
#65 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#66 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#67 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
#68 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#69 StatefulElement.update (package:flutter/src/widgets/framework.dart:5485:5)
#70 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#71 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#72 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
#73 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#74 StatefulElement.update (package:flutter/src/widgets/framework.dart:5485:5)
#75 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#76 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6441:14)
#77 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#78 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#79 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
#80 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#81 StatefulElement.update (package:flutter/src/widgets/framework.dart:5485:5)
#82 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#83 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#84 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
#85 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#86 StatefulElement.update (package:flutter/src/widgets/framework.dart:5485:5)
#87 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#88 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6441:14)
#89 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#90 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#91 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
#92 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#93 StatefulElement.update (package:flutter/src/widgets/framework.dart:5485:5)
#94 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#95 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6441:14)
#96 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#97 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6441:14)
#98 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#99 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6441:14)
#100 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)
#101 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)
#102 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
#103 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#104 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2779:19)
#105 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:916:21)
#106 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:360:5)
#107 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1297:15)
#108 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1227:9)
#109 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1085:5)
#110 _invoke (dart:ui/hooks.dart:170:13)
#111 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:401:5)
#112 _drawFrame (dart:ui/hooks.dart:140:31)
===========================================================================
答: 暂无答案
评论