diff --git a/packages/flutter/lib/src/material/reorderable_list.dart b/packages/flutter/lib/src/material/reorderable_list.dart index a9974e1ee0c..b071f2ef8ab 100644 --- a/packages/flutter/lib/src/material/reorderable_list.dart +++ b/packages/flutter/lib/src/material/reorderable_list.dart @@ -206,9 +206,6 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T // the currently dragging widget, such as when it first builds. static const double _defaultDropAreaExtent = 100.0; - // The additional margin to place around a computed drop area. - static const double _dropAreaMargin = 8.0; - // How long an animation to reorder an element in the list takes. static const Duration _reorderAnimationDuration = Duration(milliseconds: 200); @@ -264,7 +261,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T dropAreaWithoutMargin = _draggingFeedbackSize.height; break; } - return dropAreaWithoutMargin + _dropAreaMargin; + return dropAreaWithoutMargin; } @override diff --git a/packages/flutter/test/material/reorderable_list_test.dart b/packages/flutter/test/material/reorderable_list_test.dart index 0a2af39b916..fe3d47ddbe2 100644 --- a/packages/flutter/test/material/reorderable_list_test.dart +++ b/packages/flutter/test/material/reorderable_list_test.dart @@ -177,11 +177,9 @@ void main() { return contentElement; } - const double kNonDraggingListHeight = 292.0; - // The list view pads the drop area by 8dp. - const double kDraggingListHeight = 300.0; + const double kDraggingListHeight = 292.0; // Drag a normal text item - expect(getContentElement().size.height, kNonDraggingListHeight); + expect(getContentElement().size.height, kDraggingListHeight); TestGesture drag = await tester.startGesture(tester.getCenter(find.text('Normal item'))); await tester.pump(kLongPressTimeout + kPressTimeout); await tester.pumpAndSettle(); @@ -195,7 +193,7 @@ void main() { // Drop it await drag.up(); await tester.pumpAndSettle(); - expect(getContentElement().size.height, kNonDraggingListHeight); + expect(getContentElement().size.height, kDraggingListHeight); // Drag a tall item drag = await tester.startGesture(tester.getCenter(find.text('Tall item'))); @@ -210,7 +208,48 @@ void main() { // Drop it await drag.up(); await tester.pumpAndSettle(); - expect(getContentElement().size.height, kNonDraggingListHeight); + expect(getContentElement().size.height, kDraggingListHeight); + }); + + testWidgets('Vertical drop area golden', (WidgetTester tester) async { + final Widget reorderableListView = ReorderableListView( + children: [ + Container( + key: const Key('pink'), + width: double.infinity, + height: itemHeight, + color: Colors.pink, + ), + Container( + key: const Key('blue'), + width: double.infinity, + height: itemHeight, + color: Colors.blue, + ), + Container( + key: const Key('green'), + width: double.infinity, + height: itemHeight, + color: Colors.green, + ), + ], + scrollDirection: Axis.vertical, + onReorder: (int oldIndex, int newIndex) { }, + ); + await tester.pumpWidget(MaterialApp( + home: SizedBox( + height: itemHeight * 3, + child: reorderableListView, + ), + )); + + await tester.startGesture(tester.getCenter(find.byKey(const Key('blue')))); + await tester.pump(kLongPressTimeout + kPressTimeout); + await tester.pumpAndSettle(); + await expectLater( + find.byKey(const Key('blue')), + matchesGoldenFile('reorderable_list_test.vertical.drop_area.png'), + ); }); testWidgets('Preserves children states when the list parent changes the order', (WidgetTester tester) async { @@ -721,11 +760,9 @@ void main() { return contentElement; } - const double kNonDraggingListWidth = 292.0; - // The list view pads the drop area by 8dp. - const double kDraggingListWidth = 300.0; + const double kDraggingListWidth = 292.0; // Drag a normal text item - expect(getContentElement().size.width, kNonDraggingListWidth); + expect(getContentElement().size.width, kDraggingListWidth); TestGesture drag = await tester.startGesture(tester.getCenter(find.text('Normal item'))); await tester.pump(kLongPressTimeout + kPressTimeout); await tester.pumpAndSettle(); @@ -739,7 +776,7 @@ void main() { // Drop it await drag.up(); await tester.pumpAndSettle(); - expect(getContentElement().size.width, kNonDraggingListWidth); + expect(getContentElement().size.width, kDraggingListWidth); // Drag a tall item drag = await tester.startGesture(tester.getCenter(find.text('Tall item'))); @@ -754,9 +791,49 @@ void main() { // Drop it await drag.up(); await tester.pumpAndSettle(); - expect(getContentElement().size.width, kNonDraggingListWidth); + expect(getContentElement().size.width, kDraggingListWidth); }); + testWidgets('Horizontal drop area golden', (WidgetTester tester) async { + final Widget reorderableListView = ReorderableListView( + children: [ + Container( + key: const Key('pink'), + height: double.infinity, + width: itemHeight, + color: Colors.pink, + ), + Container( + key: const Key('blue'), + height: double.infinity, + width: itemHeight, + color: Colors.blue, + ), + Container( + key: const Key('green'), + height: double.infinity, + width: itemHeight, + color: Colors.green, + ), + ], + scrollDirection: Axis.horizontal, + onReorder: (int oldIndex, int newIndex) { }, + ); + await tester.pumpWidget(MaterialApp( + home: SizedBox( + width: itemHeight * 3, + child: reorderableListView, + ), + )); + + await tester.startGesture(tester.getCenter(find.byKey(const Key('blue')))); + await tester.pump(kLongPressTimeout + kPressTimeout); + await tester.pumpAndSettle(); + await expectLater( + find.byKey(const Key('blue')), + matchesGoldenFile('reorderable_list_test.horizontal.drop_area.png'), + ); + }); testWidgets('Preserves children states when the list parent changes the order', (WidgetTester tester) async { _StatefulState findState(Key key) {