Fix some leaks and add test to test cover remaining in a simple way. (#131373)
Contributes to https://github.com/flutter/flutter/issues/130467 Filed issue: https://github.com/flutter/flutter/issues/132620
This commit is contained in:
parent
371a9fc835
commit
112f4293dc
@ -81,6 +81,7 @@ class ContextMenuController {
|
||||
/// * [remove], which removes only the current instance.
|
||||
static void removeAny() {
|
||||
_menuOverlayEntry?.remove();
|
||||
_menuOverlayEntry?.dispose();
|
||||
_menuOverlayEntry = null;
|
||||
if (_shownInstance != null) {
|
||||
_shownInstance!.onRemove?.call();
|
||||
|
@ -1371,7 +1371,9 @@ class SelectionOverlay {
|
||||
void hideHandles() {
|
||||
if (_handles != null) {
|
||||
_handles![0].remove();
|
||||
_handles![0].dispose();
|
||||
_handles![1].remove();
|
||||
_handles![1].dispose();
|
||||
_handles = null;
|
||||
}
|
||||
}
|
||||
@ -1480,7 +1482,9 @@ class SelectionOverlay {
|
||||
_magnifierController.hide();
|
||||
if (_handles != null) {
|
||||
_handles![0].remove();
|
||||
_handles![0].dispose();
|
||||
_handles![1].remove();
|
||||
_handles![1].dispose();
|
||||
_handles = null;
|
||||
}
|
||||
if (_toolbar != null || _contextMenuController.isShown || _spellCheckToolbarController.isShown) {
|
||||
@ -1500,6 +1504,7 @@ class SelectionOverlay {
|
||||
return;
|
||||
}
|
||||
_toolbar?.remove();
|
||||
_toolbar?.dispose();
|
||||
_toolbar = null;
|
||||
}
|
||||
|
||||
@ -1508,6 +1513,7 @@ class SelectionOverlay {
|
||||
/// {@endtemplate}
|
||||
void dispose() {
|
||||
hide();
|
||||
_magnifierInfo.dispose();
|
||||
}
|
||||
|
||||
Widget _buildStartHandle(BuildContext context) {
|
||||
|
@ -251,6 +251,40 @@ void main() {
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(allowAllNotDisposed: true, allowAllNotGCed: true),
|
||||
);
|
||||
|
||||
testWidgetsWithLeakTracking(
|
||||
'$SelectionOverlay is not leaking',
|
||||
(WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController(
|
||||
text: 'blah1 blah2',
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Material(
|
||||
child: Center(
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final Offset startBlah1 = textOffsetToPosition(tester, 0);
|
||||
await tester.tapAt(startBlah1);
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.tapAt(startBlah1);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
controller.dispose();
|
||||
},
|
||||
skip: kIsWeb, // [intended] we don't supply the cut/copy/paste buttons on the web.
|
||||
// TODO(polina-c): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/132620
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
notDisposedAllowList: <String, int?>{'_InputBorderGap' : 1},
|
||||
),
|
||||
);
|
||||
|
||||
testWidgets('the desktop cut/copy/paste buttons are disabled for read-only obscured form fields', (WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController(
|
||||
text: 'blah1 blah2',
|
||||
|
Loading…
x
Reference in New Issue
Block a user