Closed jihchao closed 2 years ago
If I'm understand right you are trying to disable drag gesture, there is already defined property disabledGestures
I want to use gestures , but I don't want to use gestures in the drawer area because I need the ListTile
in the drawer to slide left and right.
for example(Slidable
widget is flutter_slidable
plugin):
gif demo
https://lickscreen.com/img/flutter_drawer_demo.gif
@override
Widget build(BuildContext context) {
return AdvancedDrawer(
// disabledGestures: true,
disabledGesturesOnDrawer: true,
controller: _advancedDrawerController,
openRatio: 0.80,
openScale: 1,
animationCurve: Curves.linear,
animateChildDecoration: false,
backdropColor: Colors.blueGrey,
drawer: _buildDrawer(),
child: Scaffold(
appBar: AppBar(
title: const Text('demo'),
),
body: Container(
child: Text('main screen.'),
),
),
);
}
Widget _buildDrawer() {
return SafeArea(
child: Padding(
padding: EdgeInsets.all(10),
child: ListView(
children: [
Slidable(
key: const ValueKey(0),
endActionPane: ActionPane(
motion: DrawerMotion(),
children: [
SlidableAction(
onPressed: (c) {
print('delete drawer list item.');
},
backgroundColor: Color(0xFF0392CF),
foregroundColor: Colors.white,
icon: Icons.delete,
label: 'Delete',
),
],
),
child: ListTile(
title: Text('is demo'),
selectedTileColor: Colors.blueGrey[400],
selected: true,
selectedColor: Colors.white,
onTap: () {
print('drawer list item clicked.');
},
),
),
],
),
));
}
I done example with the library you are using and it works with an existing property, check this out:
Thank you for your reply. You're right.
Conflicts occur when you enable the gesture and need to slide the drawer list. Add the disabledGesturesOnDrawer option. If disabledGesturesOnDrawer is true, gestures on drawer widgets are disabled and gestures on widgets outside the drawer are still available.