先看效果:
依赖:
dependencies:
flutter_slidable: "^0.5.4"
使用:
Slidable(
actionPane: SlidableDrawerActionPane(),
actionExtentRatio: 0.25,
child: Container(
color: Colors.white,
child: ListTile(
leading: CircleAvatar(
backgroundColor: Colors.indigoAccent,
child: Text('Test'),
foregroundColor: Colors.white,
),
title: Text('Tile'),
subtitle: Text('SlidableDrawerDelegate'),
),
),
actions: <Widget>[
IconSlideAction(
caption: 'Archive',
color: Colors.blue,
icon: Icons.archive,
onTap: () => showSnackBar(_scaffoldkey, context, 'Archive'),
),
IconSlideAction(
caption: 'Share',
color: Colors.indigo,
icon: Icons.share,
onTap: () => showSnackBar(_scaffoldkey, context, 'Share'),
),
],
secondaryActions: <Widget>[
IconSlideAction(
caption: 'More',
color: Colors.black45,
icon: Icons.more_horiz,
onTap: () => showSnackBar(_scaffoldkey, context, 'More'),
),
IconSlideAction(
caption: 'Delete',
color: Colors.red,
icon: Icons.delete,
onTap: () => showSnackBar(_scaffoldkey, context, 'Delete'),
),
],
)
actionPane 选项
- SlidableBehindActionPane 先出后面的Action
- SlidableScrollActionPane 先出前面的Action
- SlidableDrawerActionPane 抽屉式Action
- SlidableStrechActionPane 拉伸式Action