Use null-aware elements in widgets/routes.dart (#181242) ## Description Adopts null-aware element syntax (`?x`) in `widgets/routes.dart`, replacing 2 instances of the verbose `if (x != null) x!` pattern in the `_ModalScopeState` widget. Towards #172188 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing. [Contributor Guide]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md [](https://www.talabat.com) [](https://github.com/search?q=org%3Aflutter+talabat&type=pullrequests) Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index 0e00d2f..dc3545b 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart
@@ -1098,10 +1098,7 @@ @override void initState() { super.initState(); - final animations = <Listenable>[ - if (widget.route.animation != null) widget.route.animation!, - if (widget.route.secondaryAnimation != null) widget.route.secondaryAnimation!, - ]; + final animations = <Listenable>[?widget.route.animation, ?widget.route.secondaryAnimation]; _listenable = Listenable.merge(animations); }