Skip to content

Commit 181a5f1

Browse files
committed
Revert flutter#160246 "Add mouseCursor parameter to ReorderableListView"
1 parent bb2d341 commit 181a5f1

File tree

2 files changed

+10
-140
lines changed

2 files changed

+10
-140
lines changed

packages/flutter/lib/src/material/reorderable_list.dart

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ class ReorderableListView extends StatefulWidget {
103103
this.clipBehavior = Clip.hardEdge,
104104
this.autoScrollerVelocityScalar,
105105
this.dragBoundaryProvider,
106-
this.mouseCursor,
107106
}) : assert(
108107
(itemExtent == null && prototypeItem == null) ||
109108
(itemExtent == null && itemExtentBuilder == null) ||
@@ -174,7 +173,6 @@ class ReorderableListView extends StatefulWidget {
174173
this.clipBehavior = Clip.hardEdge,
175174
this.autoScrollerVelocityScalar,
176175
this.dragBoundaryProvider,
177-
this.mouseCursor,
178176
}) : assert(itemCount >= 0),
179177
assert(
180178
(itemExtent == null && prototypeItem == null) ||
@@ -300,18 +298,6 @@ class ReorderableListView extends StatefulWidget {
300298
/// {@macro flutter.widgets.reorderable_list.dragBoundaryProvider}
301299
final ReorderDragBoundaryProvider? dragBoundaryProvider;
302300

303-
/// The cursor for a mouse pointer when it enters or is hovering over the drag
304-
/// handle.
305-
///
306-
/// If [mouseCursor] is a [WidgetStateMouseCursor],
307-
/// [WidgetStateProperty.resolve] is used for the following [WidgetState]s:
308-
///
309-
/// * [WidgetState.dragged].
310-
///
311-
/// If this property is null, [SystemMouseCursors.grab] will be used when
312-
/// hovering, and [SystemMouseCursors.grabbing] when dragging.
313-
final MouseCursor? mouseCursor;
314-
315301
@override
316302
State<ReorderableListView> createState() => _ReorderableListViewState();
317303
}
@@ -335,21 +321,6 @@ class _ReorderableListViewState extends State<ReorderableListView> {
335321
case TargetPlatform.linux:
336322
case TargetPlatform.windows:
337323
case TargetPlatform.macOS:
338-
final ListenableBuilder dragHandle = ListenableBuilder(
339-
listenable: _dragging,
340-
builder: (BuildContext context, Widget? child) {
341-
final MouseCursor effectiveMouseCursor = WidgetStateProperty.resolveAs<MouseCursor>(
342-
widget.mouseCursor ??
343-
const WidgetStateMouseCursor.fromMap(<WidgetStatesConstraint, MouseCursor>{
344-
WidgetState.dragged: SystemMouseCursors.grabbing,
345-
WidgetState.any: SystemMouseCursors.grab,
346-
}),
347-
<WidgetState>{if (_dragging.value) WidgetState.dragged},
348-
);
349-
return MouseRegion(cursor: effectiveMouseCursor, child: child);
350-
},
351-
child: const Icon(Icons.drag_handle),
352-
);
353324
switch (widget.scrollDirection) {
354325
case Axis.horizontal:
355326
return Stack(
@@ -363,7 +334,10 @@ class _ReorderableListViewState extends State<ReorderableListView> {
363334
bottom: 8,
364335
child: Align(
365336
alignment: AlignmentDirectional.bottomCenter,
366-
child: ReorderableDragStartListener(index: index, child: dragHandle),
337+
child: ReorderableDragStartListener(
338+
index: index,
339+
child: const Icon(Icons.drag_handle),
340+
),
367341
),
368342
),
369343
],
@@ -380,7 +354,10 @@ class _ReorderableListViewState extends State<ReorderableListView> {
380354
end: 8,
381355
child: Align(
382356
alignment: AlignmentDirectional.centerEnd,
383-
child: ReorderableDragStartListener(index: index, child: dragHandle),
357+
child: ReorderableDragStartListener(
358+
index: index,
359+
child: const Icon(Icons.drag_handle),
360+
),
384361
),
385362
),
386363
],
@@ -409,12 +386,6 @@ class _ReorderableListViewState extends State<ReorderableListView> {
409386
);
410387
}
411388

412-
@override
413-
void dispose() {
414-
_dragging.dispose();
415-
super.dispose();
416-
}
417-
418389
@override
419390
Widget build(BuildContext context) {
420391
assert(debugCheckHasMaterialLocalizations(context));
@@ -472,14 +443,8 @@ class _ReorderableListViewState extends State<ReorderableListView> {
472443
prototypeItem: widget.prototypeItem,
473444
itemCount: widget.itemCount,
474445
onReorder: widget.onReorder,
475-
onReorderStart: (int index) {
476-
_dragging.value = true;
477-
widget.onReorderStart?.call(index);
478-
},
479-
onReorderEnd: (int index) {
480-
_dragging.value = false;
481-
widget.onReorderEnd?.call(index);
482-
},
446+
onReorderStart: widget.onReorderStart,
447+
onReorderEnd: widget.onReorderEnd,
483448
proxyDecorator: widget.proxyDecorator ?? _proxyDecorator,
484449
autoScrollerVelocityScalar: widget.autoScrollerVelocityScalar,
485450
dragBoundaryProvider: widget.dragBoundaryProvider,

packages/flutter/test/material/reorderable_list_test.dart

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,101 +2318,6 @@ void main() {
23182318
await drag.up();
23192319
await tester.pumpAndSettle();
23202320
});
2321-
2322-
testWidgets('Mouse cursor behavior on the drag handle', (WidgetTester tester) async {
2323-
await tester.pumpWidget(
2324-
MaterialApp(
2325-
home: Scaffold(
2326-
body: ReorderableListView.builder(
2327-
itemBuilder: (BuildContext context, int index) {
2328-
return ReorderableDragStartListener(
2329-
key: ValueKey<int>(index),
2330-
index: index,
2331-
child: Text('$index'),
2332-
);
2333-
},
2334-
itemCount: 5,
2335-
onReorder: (int fromIndex, int toIndex) {},
2336-
),
2337-
),
2338-
),
2339-
);
2340-
2341-
final TestGesture gesture = await tester.createGesture(
2342-
kind: PointerDeviceKind.mouse,
2343-
pointer: 1,
2344-
);
2345-
await gesture.addPointer(location: tester.getCenter(find.byIcon(Icons.drag_handle).first));
2346-
await tester.pump();
2347-
expect(
2348-
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
2349-
SystemMouseCursors.grab,
2350-
);
2351-
await gesture.down(tester.getCenter(find.byIcon(Icons.drag_handle).first));
2352-
await tester.pump(kLongPressTimeout);
2353-
expect(
2354-
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
2355-
SystemMouseCursors.grabbing,
2356-
);
2357-
await gesture.up();
2358-
await tester.pumpAndSettle();
2359-
expect(
2360-
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
2361-
SystemMouseCursors.grab,
2362-
);
2363-
}, variant: TargetPlatformVariant.desktop());
2364-
2365-
testWidgets(
2366-
'Mouse cursor behavior on the drag handle can be provided',
2367-
(WidgetTester tester) async {
2368-
await tester.pumpWidget(
2369-
MaterialApp(
2370-
home: Scaffold(
2371-
body: ReorderableListView.builder(
2372-
mouseCursor:
2373-
const WidgetStateMouseCursor.fromMap(<WidgetStatesConstraint, MouseCursor>{
2374-
WidgetState.dragged: SystemMouseCursors.copy,
2375-
WidgetState.any: SystemMouseCursors.resizeColumn,
2376-
}),
2377-
itemBuilder: (BuildContext context, int index) {
2378-
return ReorderableDragStartListener(
2379-
key: ValueKey<int>(index),
2380-
index: index,
2381-
child: Text('$index'),
2382-
);
2383-
},
2384-
itemCount: 5,
2385-
onReorder: (int fromIndex, int toIndex) {},
2386-
),
2387-
),
2388-
),
2389-
);
2390-
2391-
final TestGesture gesture = await tester.createGesture(
2392-
kind: PointerDeviceKind.mouse,
2393-
pointer: 1,
2394-
);
2395-
await gesture.addPointer(location: tester.getCenter(find.byIcon(Icons.drag_handle).first));
2396-
await tester.pump();
2397-
expect(
2398-
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
2399-
SystemMouseCursors.resizeColumn,
2400-
);
2401-
await gesture.down(tester.getCenter(find.byIcon(Icons.drag_handle).first));
2402-
await tester.pump(kLongPressTimeout);
2403-
expect(
2404-
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
2405-
SystemMouseCursors.copy,
2406-
);
2407-
await gesture.up();
2408-
await tester.pumpAndSettle();
2409-
expect(
2410-
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
2411-
SystemMouseCursors.resizeColumn,
2412-
);
2413-
},
2414-
variant: TargetPlatformVariant.desktop(),
2415-
);
24162321
}
24172322

24182323
Future<void> longPressDrag(WidgetTester tester, Offset start, Offset end) async {

0 commit comments

Comments
 (0)