diff --git a/AUTHORS b/AUTHORS index 557dff97933b..7e02cf54be1c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -4,3 +4,4 @@ # Name/Organization Google Inc. +Britannio Jarrett diff --git a/packages/animations/lib/src/open_container.dart b/packages/animations/lib/src/open_container.dart index 972847502587..2454b3aeb5d5 100644 --- a/packages/animations/lib/src/open_container.dart +++ b/packages/animations/lib/src/open_container.dart @@ -97,6 +97,7 @@ class OpenContainer extends StatefulWidget { this.transitionDuration = const Duration(milliseconds: 300), this.transitionType = ContainerTransitionType.fade, this.useRootNavigator = false, + this.routeSettings, }) : assert(closedColor != null), assert(openColor != null), assert(closedElevation != null), @@ -257,6 +258,9 @@ class OpenContainer extends StatefulWidget { /// to the nearest navigator. final bool useRootNavigator; + /// Provides additional data to the [openBuilder] route pushed by the Navigator. + final RouteSettings routeSettings; + @override _OpenContainerState createState() => _OpenContainerState(); } @@ -295,6 +299,7 @@ class _OpenContainerState extends State> { transitionDuration: widget.transitionDuration, transitionType: widget.transitionType, useRootNavigator: widget.useRootNavigator, + routeSettings: widget.routeSettings, )); if (widget.onClosed != null) { widget.onClosed(data); @@ -409,6 +414,7 @@ class _OpenContainerRoute extends ModalRoute { @required this.transitionDuration, @required this.transitionType, @required this.useRootNavigator, + @required RouteSettings routeSettings, }) : assert(closedColor != null), assert(openColor != null), assert(closedElevation != null), @@ -435,7 +441,8 @@ class _OpenContainerRoute extends ModalRoute { middleColor: middleColor, ), _closedOpacityTween = _getClosedOpacityTween(transitionType), - _openOpacityTween = _getOpenOpacityTween(transitionType); + _openOpacityTween = _getOpenOpacityTween(transitionType), + super(settings: routeSettings); static _FlippableTweenSequence _getColorTween({ @required ContainerTransitionType transitionType, diff --git a/packages/animations/test/open_container_test.dart b/packages/animations/test/open_container_test.dart index cfb75f33f1b0..2628fbef9fe4 100644 --- a/packages/animations/test/open_container_test.dart +++ b/packages/animations/test/open_container_test.dart @@ -1694,6 +1694,45 @@ void main() { expect(tester.getSize(find.text('Opened')), equals(tester.getSize(find.byKey(appKey)))); }); + + testWidgets( + 'Verify routeSettings passed to Navigator', + (WidgetTester tester) async { + const RouteSettings routeSettings = RouteSettings( + name: 'route-name', + arguments: 'arguments', + ); + + final Widget openContainer = OpenContainer( + routeSettings: routeSettings, + closedBuilder: (BuildContext context, VoidCallback action) { + return GestureDetector( + onTap: action, + child: const Text('Closed'), + ); + }, + openBuilder: (BuildContext context, VoidCallback action) { + return GestureDetector( + onTap: action, + child: const Text('Open'), + ); + }, + ); + + await tester.pumpWidget(_boilerplate(child: openContainer)); + + // Open the container + await tester.tap(find.text('Closed')); + await tester.pumpAndSettle(); + + // Expect the last route pushed to the navigator to contain RouteSettings + // equal to the RouteSettings passed to the OpenContainer + final ModalRoute modalRoute = ModalRoute.of( + tester.element(find.text('Open')), + ); + expect(modalRoute.settings, routeSettings); + }, + ); } Color _getScrimColor(WidgetTester tester) {