-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: desktopRunning on desktopRunning on desktopa: qualityA truly polished experienceA truly polished experiencec: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Use case
Let's say you have a list of items and you want to enable a faster drag and drop interaction on each item. This is especially something that users on a desktop platform would expect.
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: ListView(
children: [
for (int i = 0; i < 20; i++)
Draggable<int>(
data: i,
feedback: Card(
child: Text("Contact $i"),
),
dragAnchor: DragAnchor.pointer,
child: ListTile(
leading: const Icon(Icons.contact_mail_rounded),
title: Text("Contact $i"),
),
),
],
),
floatingActionButton: DragTarget<int>(
onWillAccept: (data) => true,
builder: (context, candidateData, __) => (candidateData.isEmpty)
? FloatingActionButton(
onPressed: () {},
child: Icon(Icons.delete),
)
: FloatingActionButton.large(
onPressed: () {},
child: Icon(Icons.check),
),
),
),
);
}
}
On mouse-based devices this works fine, but on touch-based ones the regular list scroll competes with the drag gesture on each list item.
Proposal
Draggable should allow to specify which PointerDeviceKinds should be allowed to trigger a drag gesture.
A possible API example
const Draggable<T extends Object>(
{Key? key,
required Widget child,
required Widget feedback,
T? data,
...
List<PointerDeviceKind> pointerKinds = PointerDeviceKind.values,
...
)This should subsequently also be done for LongPressDraggable.
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: desktopRunning on desktopRunning on desktopa: qualityA truly polished experienceA truly polished experiencec: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team