Unverified Commit 4b89fce1 authored by Renzo Olivares's avatar Renzo Olivares Committed by GitHub

Fixing memory leak in EditableTextState (#131377)

parent d1410a11
......@@ -2125,6 +2125,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
late final Simulation _iosBlinkCursorSimulation = _DiscreteKeyFrameSimulation.iOSBlinkingCaret();
final ValueNotifier<bool> _cursorVisibilityNotifier = ValueNotifier<bool>(true);
late final ValueNotifier<bool> _debugCursorNotifier;
final GlobalKey _editableKey = GlobalKey();
/// Detects whether the clipboard can paste.
......@@ -2789,6 +2790,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
_scrollController.addListener(_onEditableScroll);
_cursorVisibilityNotifier.value = widget.showCursor;
_spellCheckConfiguration = _inferSpellCheckConfiguration(widget.spellCheckConfiguration);
_debugCursorNotifier = ValueNotifier<bool>(widget.showCursor);
}
// Whether `TickerMode.of(context)` is true and animations (like blinking the
......@@ -2933,6 +2935,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
@override
void dispose() {
_debugCursorNotifier.dispose();
_internalScrollController?.dispose();
_currentAutofillScope?.unregister(autofillId);
widget.controller.removeListener(_didChangeTextEditingValue);
......@@ -4853,7 +4856,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
cursorColor: _cursorColor,
backgroundCursorColor: widget.backgroundCursorColor,
showCursor: EditableText.debugDeterministicCursor
? ValueNotifier<bool>(widget.showCursor)
? _debugCursorNotifier
: _cursorVisibilityNotifier,
forceLine: widget.forceLine,
readOnly: widget.readOnly,
......
......@@ -167,18 +167,7 @@ void main() {
await tester.pumpAndSettle();
final RenderBox handle = tester.firstRenderObject<RenderBox>(find.byType(CustomPaint));
expect(handle, paints..path(color: defaultSelectionHandleColor));
},
// TODO(polina-c): remove after fixing
// https://github.com/flutter/flutter/issues/130469
leakTrackingTestConfig: const LeakTrackingTestConfig(
notDisposedAllowList: <String, int?>{
'ValueNotifier<MagnifierInfo>': 1,
'ValueNotifier<_OverlayEntryWidgetState?>': 2,
'ValueNotifier<bool>': 2,
'_InputBorderGap': 1,
},
),
);
});
testWidgets('ThemeData.textSelectionTheme will be used if provided', (WidgetTester tester) async {
const TextSelectionThemeData textSelectionTheme = TextSelectionThemeData(
......
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