forked from firka/flutter
fixes CupertinoModalPopupRoute (#147823)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user