Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes CupertinoModalPopupRoute #147823

Merged
merged 20 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/flutter/lib/src/cupertino/route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ class CupertinoModalPopupRoute<T> extends PopupRoute<T> {
@override
Duration get transitionDuration => _kModalPopupTransitionDuration;

Animation<double>? _animation;
CurvedAnimation? _animation;

late Tween<Offset> _offsetTween;

Expand Down Expand Up @@ -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.
Expand Down
30 changes: 30 additions & 0 deletions packages/flutter/test/cupertino/route_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down