Unverified Commit ef9befc9 authored by Renzo Olivares's avatar Renzo Olivares Committed by GitHub

Reland leak fix for EditableTextState (#133806)

Relands: https://github.com/flutter/flutter/pull/131377
Reverted in: https://github.com/flutter/flutter/pull/133804
parent 96621ebf
......@@ -2125,6 +2125,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
late final Simulation _iosBlinkCursorSimulation = _DiscreteKeyFrameSimulation.iOSBlinkingCaret();
final ValueNotifier<bool> _cursorVisibilityNotifier = ValueNotifier<bool>(true);
final ValueNotifier<bool> _debugCursorNotifier = ValueNotifier<bool>(true);
final GlobalKey _editableKey = GlobalKey();
/// Detects whether the clipboard can paste.
......@@ -2802,6 +2803,8 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
void didChangeDependencies() {
super.didChangeDependencies();
_debugCursorNotifier.value = widget.showCursor;
_style = MediaQuery.boldTextOf(context)
? widget.style.merge(const TextStyle(fontWeight: FontWeight.bold))
: widget.style;
......@@ -2956,6 +2959,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
clipboardStatus.removeListener(_onChangedClipboardStatus);
clipboardStatus.dispose();
_cursorVisibilityNotifier.dispose();
_debugCursorNotifier.dispose();
FocusManager.instance.removeListener(_unflagInternalFocus);
super.dispose();
assert(_batchEditDepth <= 0, 'unfinished batch edits: $_batchEditDepth');
......@@ -4857,7 +4861,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,
......
......@@ -105,20 +105,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,
},
// TODO(polina-c): investigate notGCed, if it does not disappear after fixing notDisposed.
allowAllNotGCed: true,
),
);
});
testWidgetsWithLeakTracking('Material3 - Empty textSelectionTheme will use defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
......@@ -167,18 +154,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