Skip to content

Commit 161c709

Browse files
authored
EditableTextState should dispose cursorVisibilityNotifier. (#133858)
1 parent 0d30546 commit 161c709

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

packages/flutter/lib/src/widgets/editable_text.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,7 +2125,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
21252125
late final Simulation _iosBlinkCursorSimulation = _DiscreteKeyFrameSimulation.iOSBlinkingCaret();
21262126

21272127
final ValueNotifier<bool> _cursorVisibilityNotifier = ValueNotifier<bool>(true);
2128-
final ValueNotifier<bool> _debugCursorNotifier = ValueNotifier<bool>(true);
21292128
final GlobalKey _editableKey = GlobalKey();
21302129

21312130
/// Detects whether the clipboard can paste.
@@ -2803,8 +2802,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
28032802
void didChangeDependencies() {
28042803
super.didChangeDependencies();
28052804

2806-
_debugCursorNotifier.value = widget.showCursor;
2807-
28082805
_style = MediaQuery.boldTextOf(context)
28092806
? widget.style.merge(const TextStyle(fontWeight: FontWeight.bold))
28102807
: widget.style;
@@ -2959,7 +2956,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
29592956
clipboardStatus.removeListener(_onChangedClipboardStatus);
29602957
clipboardStatus.dispose();
29612958
_cursorVisibilityNotifier.dispose();
2962-
_debugCursorNotifier.dispose();
29632959
FocusManager.instance.removeListener(_unflagInternalFocus);
29642960
super.dispose();
29652961
assert(_batchEditDepth <= 0, 'unfinished batch edits: $_batchEditDepth');
@@ -3879,7 +3875,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
38793875
void _onCursorColorTick() {
38803876
final double effectiveOpacity = math.min(widget.cursorColor.alpha / 255.0, _cursorBlinkOpacityController.value);
38813877
renderEditable.cursorColor = widget.cursorColor.withOpacity(effectiveOpacity);
3882-
_cursorVisibilityNotifier.value = widget.showCursor && _cursorBlinkOpacityController.value > 0;
3878+
_cursorVisibilityNotifier.value = widget.showCursor && (EditableText.debugDeterministicCursor || _cursorBlinkOpacityController.value > 0);
38833879
}
38843880

38853881
bool get _showBlinkingCursor => _hasFocus && _value.selection.isCollapsed && widget.showCursor && _tickersEnabled;
@@ -4860,9 +4856,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
48604856
value: _value,
48614857
cursorColor: _cursorColor,
48624858
backgroundCursorColor: widget.backgroundCursorColor,
4863-
showCursor: EditableText.debugDeterministicCursor
4864-
? _debugCursorNotifier
4865-
: _cursorVisibilityNotifier,
4859+
showCursor: _cursorVisibilityNotifier,
48664860
forceLine: widget.forceLine,
48674861
readOnly: widget.readOnly,
48684862
hasFocus: _hasFocus,

0 commit comments

Comments
 (0)