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