Unverified Commit 0d198c7b authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

SearchDelegate should dispose resources. (#133948)

parent 2867b31f
......@@ -377,6 +377,15 @@ abstract class SearchDelegate<T> {
}
_SearchPageRoute<T>? _route;
/// Releases the resources.
@mustCallSuper
void dispose() {
_currentBodyNotifier.dispose();
_focusNode?.dispose();
_queryTextController.dispose();
_proxyAnimation.parent = null;
}
}
/// Describes the body that is currently shown under the [AppBar] in the
......
......@@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/clipboard_utils.dart';
import '../widgets/semantics_tester.dart';
......@@ -25,8 +26,9 @@ void main() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null);
});
testWidgets('Changing query moves cursor to the end of query', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Changing query moves cursor to the end of query', (WidgetTester tester) async {
final _TestSearchDelegate delegate = _TestSearchDelegate();
addTearDown(() => delegate.dispose());
await tester.pumpWidget(TestHomePage(delegate: delegate));
await tester.tap(find.byTooltip('Search'));
......
......@@ -22,9 +22,7 @@ Widget boilerplate({required Widget child}) {
void main() {
testWidgetsWithLeakTracking('SegmentedButton is built with Material of type MaterialType.transparency',
leakTrackingTestConfig: LeakTrackingTestConfig.debugNotDisposed(),
(WidgetTester tester) async {
testWidgetsWithLeakTracking('SegmentedButton is built with Material of type MaterialType.transparency', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
......
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