diff --git a/AUTHORS b/AUTHORS index 7e02cf54be..3bdb8413f0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -5,3 +5,4 @@ Google Inc. Britannio Jarrett +Sarbagya Dhaubanjar \ No newline at end of file diff --git a/packages/animations/lib/src/open_container.dart b/packages/animations/lib/src/open_container.dart index 7510153192..0a1252ce5d 100644 --- a/packages/animations/lib/src/open_container.dart +++ b/packages/animations/lib/src/open_container.dart @@ -98,6 +98,7 @@ class OpenContainer extends StatefulWidget { this.transitionType = ContainerTransitionType.fade, this.useRootNavigator = false, this.routeSettings, + this.clipBehavior = Clip.antiAlias, }) : super(key: key); /// Background color of the container while it is closed. @@ -250,6 +251,15 @@ class OpenContainer extends StatefulWidget { /// Provides additional data to the [openBuilder] route pushed by the Navigator. final RouteSettings? routeSettings; + /// The [closedBuilder] will be clipped (or not) according to this option. + /// + /// Defaults to [Clip.antiAlias], and must not be null. + /// + /// See also: + /// + /// * [Material.clipBehavior], which is used to implement this property. + final Clip clipBehavior; + @override _OpenContainerState createState() => _OpenContainerState(); } @@ -302,7 +312,7 @@ class _OpenContainerState extends State> { child: GestureDetector( onTap: widget.tappable ? openContainer : null, child: Material( - clipBehavior: Clip.antiAlias, + clipBehavior: widget.clipBehavior, color: widget.closedColor, elevation: widget.closedElevation, shape: widget.closedShape, diff --git a/packages/animations/test/open_container_test.dart b/packages/animations/test/open_container_test.dart index 3ab05f2cf2..afc0eb29bf 100644 --- a/packages/animations/test/open_container_test.dart +++ b/packages/animations/test/open_container_test.dart @@ -1572,6 +1572,62 @@ void main() { expect(value, isTrue); }); + testWidgets('closedBuilder has anti-alias clip by default', + (WidgetTester tester) async { + final GlobalKey closedBuilderKey = GlobalKey(); + final Widget openContainer = OpenContainer( + closedBuilder: (BuildContext context, VoidCallback action) { + return Text('Close', key: closedBuilderKey); + }, + openBuilder: + (BuildContext context, CloseContainerActionCallback action) { + return const Text('Open'); + }, + ); + + await tester.pumpWidget( + _boilerplate(child: openContainer), + ); + + final Finder closedBuilderMaterial = find + .ancestor( + of: find.byKey(closedBuilderKey), + matching: find.byType(Material), + ) + .first; + + final Material material = tester.widget(closedBuilderMaterial); + expect(material.clipBehavior, Clip.antiAlias); + }); + + testWidgets('closedBuilder has no clip', (WidgetTester tester) async { + final GlobalKey closedBuilderKey = GlobalKey(); + final Widget openContainer = OpenContainer( + closedBuilder: (BuildContext context, VoidCallback action) { + return Text('Close', key: closedBuilderKey); + }, + openBuilder: + (BuildContext context, CloseContainerActionCallback action) { + return const Text('Open'); + }, + clipBehavior: Clip.none, + ); + + await tester.pumpWidget( + _boilerplate(child: openContainer), + ); + + final Finder closedBuilderMaterial = find + .ancestor( + of: find.byKey(closedBuilderKey), + matching: find.byType(Material), + ) + .first; + + final Material material = tester.widget(closedBuilderMaterial); + expect(material.clipBehavior, Clip.none); + }); + Widget _createRootNavigatorTest({ required Key appKey, required Key nestedNavigatorKey,