fixes CupertinoModalPopupRoute (#147823)

This commit is contained in:
Dimil Kalathiya
2024-05-20 23:13:18 +05:30
committed by GitHub
parent 76a07a1646
commit e2de8d80f6
2 changed files with 37 additions and 1 deletions

View File

@@ -1096,7 +1096,7 @@ class CupertinoModalPopupRoute<T> extends PopupRoute<T> {
@override
Duration get transitionDuration => _kModalPopupTransitionDuration;
Animation<double>? _animation;
CurvedAnimation? _animation;
late Tween<Offset> _offsetTween;
@@ -1142,6 +1142,12 @@ class CupertinoModalPopupRoute<T> extends PopupRoute<T> {
),
);
}
@override
void dispose() {
_animation?.dispose();
super.dispose();
}
}
/// Shows a modal iOS-style popup that slides up from the bottom of the screen.

View File

@@ -2666,6 +2666,36 @@ void main() {
await tester.pump(const Duration(milliseconds: 400));
});
testWidgets('CupertinoModalPopupRoute does not leak CurveAnimation',
// TODO(polina-c): remove when fixed https://github.com/flutter/flutter/issues/145600 [leak-tracking-opt-in]
experimentalLeakTesting: LeakTesting.settings.withTracked(classes: <String>['CurvedAnimation']),
(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Navigator(
onGenerateRoute: (RouteSettings settings) {
return PageRouteBuilder<dynamic>(
pageBuilder: (BuildContext context, Animation<double> _, Animation<double> __) {
return GestureDetector(
onTap: () async {
await showCupertinoModalPopup<void>(
context: context,
semanticsDismissible: true,
builder: (BuildContext context) => const SizedBox(),
);
},
child: const Text('tap'),
);
},
);
},
),
));
// Push the route.
await tester.tap(find.text('tap'));
await tester.pumpAndSettle();
});
}
class MockNavigatorObserver extends NavigatorObserver {