diff --git a/packages/flutter/lib/src/widgets/animated_list.dart b/packages/flutter/lib/src/widgets/animated_list.dart index b69b502df4..07d1a1c915 100644 --- a/packages/flutter/lib/src/widgets/animated_list.dart +++ b/packages/flutter/lib/src/widgets/animated_list.dart @@ -276,6 +276,7 @@ class AnimatedList extends StatefulWidget { this.physics, this.shrinkWrap = false, this.padding, + this.clipBehavior = Clip.hardEdge, }) : assert(itemBuilder != null), assert(initialItemCount != null && initialItemCount >= 0), super(key: key); @@ -373,6 +374,11 @@ class AnimatedList extends StatefulWidget { /// The amount of space by which to inset the children. final EdgeInsetsGeometry? padding; + /// {@macro flutter.material.Material.clipBehavior} + /// + /// Defaults to [Clip.hardEdge]. + final Clip clipBehavior; + /// The state from the closest instance of this class that encloses the given /// context. /// @@ -493,6 +499,7 @@ class AnimatedListState extends State with TickerProviderStateMixi primary: widget.primary, physics: widget.physics, shrinkWrap: widget.shrinkWrap, + clipBehavior: widget.clipBehavior, slivers: [ SliverPadding( padding: widget.padding ?? EdgeInsets.zero, diff --git a/packages/flutter/test/widgets/animated_list_test.dart b/packages/flutter/test/widgets/animated_list_test.dart index 86a60b4cf5..73a061f937 100644 --- a/packages/flutter/test/widgets/animated_list_test.dart +++ b/packages/flutter/test/widgets/animated_list_test.dart @@ -363,4 +363,28 @@ void main() { ), ); }); + + testWidgets('AnimatedList.clipBehavior is forwarded to its inner CustomScrollView', (WidgetTester tester) async { + const Clip clipBehavior = Clip.none; + + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: AnimatedList( + initialItemCount: 2, + clipBehavior: clipBehavior, + itemBuilder: (BuildContext context, int index, Animation _) { + return SizedBox( + height: 100.0, + child: Center( + child: Text('item $index'), + ), + ); + }, + ), + ), + ); + + expect(tester.widget(find.byType(CustomScrollView)).clipBehavior, clipBehavior); + }); }