Make sure that an AnimatedList doesn't crash in 0x0 environment (#180123)
This is my attempt to handle
https://github.com/flutter/flutter/issues/6537 for the AnimatedList
widget.
Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
diff --git a/packages/flutter/test/widgets/animated_list_test.dart b/packages/flutter/test/widgets/animated_list_test.dart
index 3fb5835..7d8717e 100644
--- a/packages/flutter/test/widgets/animated_list_test.dart
+++ b/packages/flutter/test/widgets/animated_list_test.dart
@@ -1160,6 +1160,28 @@
expect(itemsSeparatorsTexts[1].data, 'separator after item 0');
expect(itemsSeparatorsTexts[2].data, 'item 1');
});
+
+ testWidgets('AnimatedList does not crash at zero area', (WidgetTester tester) async {
+ tester.view.physicalSize = Size.zero;
+ final controller = ScrollController();
+ addTearDown(tester.view.reset);
+ addTearDown(controller.dispose);
+ await tester.pumpWidget(
+ Directionality(
+ textDirection: TextDirection.ltr,
+ child: Center(
+ child: AnimatedList(controller: controller, itemBuilder: (_, i, _) => Text('$i')),
+ ),
+ ),
+ );
+ expect(tester.getSize(find.byType(AnimatedList)), Size.zero);
+ await controller.animateTo(
+ 0,
+ duration: const Duration(milliseconds: 250),
+ curve: Curves.bounceIn,
+ );
+ await tester.pump();
+ });
}
class _StatefulListItem extends StatefulWidget {