Skip to content

Commit d413081

Browse files
authored
Fix shrinkwrap on animated list (#115104)
1 parent 4e7dbef commit d413081

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

packages/flutter/lib/src/widgets/animated_scroll_view.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ abstract class _AnimatedScrollViewState<T extends _AnimatedScrollView> extends S
521521
primary: widget.primary,
522522
physics: widget.physics,
523523
clipBehavior: widget.clipBehavior,
524+
shrinkWrap: widget.shrinkWrap,
524525
slivers: <Widget>[
525526
SliverPadding(
526527
padding: widget.padding ?? EdgeInsets.zero,

packages/flutter/test/widgets/animated_list_test.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,31 @@ void main() {
488488

489489
expect(tester.widget<CustomScrollView>(find.byType(CustomScrollView)).clipBehavior, clipBehavior);
490490
});
491+
492+
testWidgets('AnimatedList.shrinkwrap is forwarded to its inner CustomScrollView', (WidgetTester tester) async {
493+
// Regression test for https://github.com/flutter/flutter/issues/115040
494+
final ScrollController controller = ScrollController();
495+
await tester.pumpWidget(
496+
Directionality(
497+
textDirection: TextDirection.ltr,
498+
child: AnimatedList(
499+
controller: controller,
500+
initialItemCount: 2,
501+
shrinkWrap: true,
502+
itemBuilder: (BuildContext context, int index, Animation<double> _) {
503+
return SizedBox(
504+
height: 100.0,
505+
child: Center(
506+
child: Text('Item $index'),
507+
),
508+
);
509+
},
510+
),
511+
),
512+
);
513+
514+
expect(tester.widget<CustomScrollView>(find.byType(CustomScrollView)).shrinkWrap, true);
515+
});
491516
}
492517

493518

0 commit comments

Comments
 (0)