expose clipBehavior (#74046)

This commit is contained in:
Pedro Massango
2021-01-27 23:54:46 +01:00
committed by GitHub
parent 4fa250f3f7
commit a2ce206695
2 changed files with 31 additions and 0 deletions

View File

@@ -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,

View File

@@ -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);
});
}