Unverified Commit 1c0b4ad5 authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

_SearchBarState should dispose FocusNode, if it created it. (#134076)

Relanding of revert: https://github.com/flutter/flutter/pull/134072

Verified failed tests succeeded now:
parent 5a8a20c6
...@@ -1179,6 +1179,9 @@ class _SearchBarState extends State<SearchBar> { ...@@ -1179,6 +1179,9 @@ class _SearchBarState extends State<SearchBar> {
@override @override
void dispose() { void dispose() {
_internalStatesController.dispose(); _internalStatesController.dispose();
if (widget.focusNode == null) {
_focusNode.dispose();
}
super.dispose(); super.dispose();
} }
......
...@@ -6,9 +6,10 @@ import 'dart:ui'; ...@@ -6,9 +6,10 @@ import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('SearchBar defaults', (WidgetTester tester) async { testWidgetsWithLeakTracking('SearchBar defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
final ColorScheme colorScheme = theme.colorScheme; final ColorScheme colorScheme = theme.colorScheme;
......
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