Fix shrinkwrap on animated list (#115104)

This commit is contained in:
Kate Lovett 2022-11-10 16:20:06 -06:00 committed by GitHub
parent 4e7dbefd92
commit d41308179a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -521,6 +521,7 @@ abstract class _AnimatedScrollViewState<T extends _AnimatedScrollView> extends S
primary: widget.primary,
physics: widget.physics,
clipBehavior: widget.clipBehavior,
shrinkWrap: widget.shrinkWrap,
slivers: <Widget>[
SliverPadding(
padding: widget.padding ?? EdgeInsets.zero,

View File

@ -488,6 +488,31 @@ void main() {
expect(tester.widget<CustomScrollView>(find.byType(CustomScrollView)).clipBehavior, clipBehavior);
});
testWidgets('AnimatedList.shrinkwrap is forwarded to its inner CustomScrollView', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/115040
final ScrollController controller = ScrollController();
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: AnimatedList(
controller: controller,
initialItemCount: 2,
shrinkWrap: true,
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)).shrinkWrap, true);
});
}