Unverified Commit 61a388a4 authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

Fix not disposed items in Cupertino app and route. (#134085)

parent 99f5cf07
...@@ -506,6 +506,12 @@ class _CupertinoAppState extends State<CupertinoApp> { ...@@ -506,6 +506,12 @@ class _CupertinoAppState extends State<CupertinoApp> {
_heroController = CupertinoApp.createCupertinoHeroController(); _heroController = CupertinoApp.createCupertinoHeroController();
} }
@override
void dispose() {
_heroController.dispose();
super.dispose();
}
// Combine the default localization for Cupertino with the ones contributed // Combine the default localization for Cupertino with the ones contributed
// by the localizationsDelegates parameter, if any. Only the first delegate // by the localizationsDelegates parameter, if any. Only the first delegate
// of a particular LocalizationsDelegate.type is loaded so the // of a particular LocalizationsDelegate.type is loaded so the
......
...@@ -121,6 +121,12 @@ mixin CupertinoRouteTransitionMixin<T> on PageRoute<T> { ...@@ -121,6 +121,12 @@ mixin CupertinoRouteTransitionMixin<T> on PageRoute<T> {
return _previousTitle!; return _previousTitle!;
} }
@override
void dispose() {
_previousTitle?.dispose();
super.dispose();
}
@override @override
void didChangePrevious(Route<dynamic>? previousRoute) { void didChangePrevious(Route<dynamic>? previousRoute) {
final String? previousTitleString = previousRoute is CupertinoRouteTransitionMixin final String? previousTitleString = previousRoute is CupertinoRouteTransitionMixin
......
...@@ -7,9 +7,10 @@ import 'package:flutter/foundation.dart'; ...@@ -7,9 +7,10 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.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('Heroes work', (WidgetTester tester) async { testWidgetsWithLeakTracking('Heroes work', (WidgetTester tester) async {
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: ListView(children: <Widget>[ home: ListView(children: <Widget>[
const Hero(tag: 'a', child: Text('foo')), const Hero(tag: 'a', child: Text('foo')),
...@@ -394,6 +395,11 @@ void main() { ...@@ -394,6 +395,11 @@ void main() {
return renderEditable!; return renderEditable!;
} }
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
final TextEditingController controller = TextEditingController();
addTearDown(controller.dispose);
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
theme: const CupertinoThemeData( theme: const CupertinoThemeData(
...@@ -405,8 +411,8 @@ void main() { ...@@ -405,8 +411,8 @@ void main() {
return EditableText( return EditableText(
backgroundCursorColor: DefaultSelectionStyle.of(context).selectionColor!, backgroundCursorColor: DefaultSelectionStyle.of(context).selectionColor!,
cursorColor: DefaultSelectionStyle.of(context).cursorColor!, cursorColor: DefaultSelectionStyle.of(context).cursorColor!,
controller: TextEditingController(), controller: controller,
focusNode: FocusNode(), focusNode: focusNode,
style: const TextStyle(), style: const TextStyle(),
); );
}, },
......
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