Unverified Commit 161c7090 authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

EditableTextState should dispose cursorVisibilityNotifier. (#133858)

parent 0d30546c
...@@ -2125,7 +2125,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien ...@@ -2125,7 +2125,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
late final Simulation _iosBlinkCursorSimulation = _DiscreteKeyFrameSimulation.iOSBlinkingCaret(); late final Simulation _iosBlinkCursorSimulation = _DiscreteKeyFrameSimulation.iOSBlinkingCaret();
final ValueNotifier<bool> _cursorVisibilityNotifier = ValueNotifier<bool>(true); final ValueNotifier<bool> _cursorVisibilityNotifier = ValueNotifier<bool>(true);
final ValueNotifier<bool> _debugCursorNotifier = ValueNotifier<bool>(true);
final GlobalKey _editableKey = GlobalKey(); final GlobalKey _editableKey = GlobalKey();
/// Detects whether the clipboard can paste. /// Detects whether the clipboard can paste.
...@@ -2803,8 +2802,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien ...@@ -2803,8 +2802,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
_debugCursorNotifier.value = widget.showCursor;
_style = MediaQuery.boldTextOf(context) _style = MediaQuery.boldTextOf(context)
? widget.style.merge(const TextStyle(fontWeight: FontWeight.bold)) ? widget.style.merge(const TextStyle(fontWeight: FontWeight.bold))
: widget.style; : widget.style;
...@@ -2959,7 +2956,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien ...@@ -2959,7 +2956,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
clipboardStatus.removeListener(_onChangedClipboardStatus); clipboardStatus.removeListener(_onChangedClipboardStatus);
clipboardStatus.dispose(); clipboardStatus.dispose();
_cursorVisibilityNotifier.dispose(); _cursorVisibilityNotifier.dispose();
_debugCursorNotifier.dispose();
FocusManager.instance.removeListener(_unflagInternalFocus); FocusManager.instance.removeListener(_unflagInternalFocus);
super.dispose(); super.dispose();
assert(_batchEditDepth <= 0, 'unfinished batch edits: $_batchEditDepth'); assert(_batchEditDepth <= 0, 'unfinished batch edits: $_batchEditDepth');
...@@ -3879,7 +3875,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien ...@@ -3879,7 +3875,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
void _onCursorColorTick() { void _onCursorColorTick() {
final double effectiveOpacity = math.min(widget.cursorColor.alpha / 255.0, _cursorBlinkOpacityController.value); final double effectiveOpacity = math.min(widget.cursorColor.alpha / 255.0, _cursorBlinkOpacityController.value);
renderEditable.cursorColor = widget.cursorColor.withOpacity(effectiveOpacity); renderEditable.cursorColor = widget.cursorColor.withOpacity(effectiveOpacity);
_cursorVisibilityNotifier.value = widget.showCursor && _cursorBlinkOpacityController.value > 0; _cursorVisibilityNotifier.value = widget.showCursor && (EditableText.debugDeterministicCursor || _cursorBlinkOpacityController.value > 0);
} }
bool get _showBlinkingCursor => _hasFocus && _value.selection.isCollapsed && widget.showCursor && _tickersEnabled; bool get _showBlinkingCursor => _hasFocus && _value.selection.isCollapsed && widget.showCursor && _tickersEnabled;
...@@ -4860,9 +4856,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien ...@@ -4860,9 +4856,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
value: _value, value: _value,
cursorColor: _cursorColor, cursorColor: _cursorColor,
backgroundCursorColor: widget.backgroundCursorColor, backgroundCursorColor: widget.backgroundCursorColor,
showCursor: EditableText.debugDeterministicCursor showCursor: _cursorVisibilityNotifier,
? _debugCursorNotifier
: _cursorVisibilityNotifier,
forceLine: widget.forceLine, forceLine: widget.forceLine,
readOnly: widget.readOnly, readOnly: widget.readOnly,
hasFocus: _hasFocus, hasFocus: _hasFocus,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment