Unverified Commit a2ce2066 authored by Pedro Massango's avatar Pedro Massango Committed by GitHub

expose clipBehavior (#74046)

parent 4fa250f3
......@@ -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<AnimatedList> with TickerProviderStateMixi
primary: widget.primary,
physics: widget.physics,
shrinkWrap: widget.shrinkWrap,
clipBehavior: widget.clipBehavior,
slivers: <Widget>[
SliverPadding(
padding: widget.padding ?? EdgeInsets.zero,
......
......@@ -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<double> _) {
return SizedBox(
height: 100.0,
child: Center(
child: Text('item $index'),
),
);
},
),
),
);
expect(tester.widget<CustomScrollView>(find.byType(CustomScrollView)).clipBehavior, clipBehavior);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment