Skip to content

Commit 2d9a075

Browse files
authored
Cover text_selection tests with leak tracking. (#137009)
1 parent db57d28 commit 2d9a075

File tree

3 files changed

+141
-58
lines changed

3 files changed

+141
-58
lines changed

packages/flutter/lib/src/rendering/editable.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
364364
_readOnly = readOnly,
365365
_forceLine = forceLine,
366366
_clipBehavior = clipBehavior,
367-
_hasFocus = hasFocus ?? false {
367+
_hasFocus = hasFocus ?? false,
368+
_disposeShowCursor = showCursor == null {
368369
assert(!_showCursor.value || cursorColor != null);
369370

370371
_selectionPainter.highlightColor = selectionColor;
@@ -405,6 +406,10 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
405406
_selectionPainter.dispose();
406407
_caretPainter.dispose();
407408
_textPainter.dispose();
409+
if (_disposeShowCursor) {
410+
_showCursor.dispose();
411+
_disposeShowCursor = false;
412+
}
408413
super.dispose();
409414
}
410415

@@ -879,6 +884,8 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
879884
_caretPainter.backgroundCursorColor = value;
880885
}
881886

887+
bool _disposeShowCursor;
888+
882889
/// Whether to paint the cursor.
883890
ValueNotifier<bool> get showCursor => _showCursor;
884891
ValueNotifier<bool> _showCursor;
@@ -889,6 +896,10 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
889896
if (attached) {
890897
_showCursor.removeListener(_showHideCursor);
891898
}
899+
if (_disposeShowCursor) {
900+
_showCursor.dispose();
901+
_disposeShowCursor = false;
902+
}
892903
_showCursor = value;
893904
if (attached) {
894905
_showHideCursor();

0 commit comments

Comments
 (0)