@@ -441,9 +441,10 @@ class RenderEditableTextLine extends RenderEditableBox {
441
441
}
442
442
443
443
final containsSelection = containsTextSelection ();
444
- if (attached && containsCursor () ) {
444
+ if (_attachedToCursorController ) {
445
445
cursorCont.removeListener (markNeedsLayout);
446
446
cursorCont.color.removeListener (safeMarkNeedsPaint);
447
+ _attachedToCursorController = false ;
447
448
}
448
449
449
450
textSelection = t;
@@ -452,6 +453,7 @@ class RenderEditableTextLine extends RenderEditableBox {
452
453
if (attached && containsCursor ()) {
453
454
cursorCont.addListener (markNeedsLayout);
454
455
cursorCont.color.addListener (safeMarkNeedsPaint);
456
+ _attachedToCursorController = true ;
455
457
}
456
458
457
459
if (containsSelection || containsTextSelection ()) {
@@ -680,6 +682,8 @@ class RenderEditableTextLine extends RenderEditableBox {
680
682
681
683
// Start render box overrides
682
684
685
+ bool _attachedToCursorController = false ;
686
+
683
687
@override
684
688
void attach (covariant PipelineOwner owner) {
685
689
super .attach (owner);
@@ -690,6 +694,7 @@ class RenderEditableTextLine extends RenderEditableBox {
690
694
if (containsCursor ()) {
691
695
cursorCont.addListener (markNeedsLayout);
692
696
cursorCont.color.addListener (safeMarkNeedsPaint);
697
+ _attachedToCursorController = true ;
693
698
}
694
699
}
695
700
@@ -701,9 +706,10 @@ class RenderEditableTextLine extends RenderEditableBox {
701
706
}
702
707
cursorCont.floatingCursorTextPosition
703
708
.removeListener (_onFloatingCursorChange);
704
- if (containsCursor () ) {
709
+ if (_attachedToCursorController ) {
705
710
cursorCont.removeListener (markNeedsLayout);
706
711
cursorCont.color.removeListener (safeMarkNeedsPaint);
712
+ _attachedToCursorController = false ;
707
713
}
708
714
}
709
715
0 commit comments