列表视图项目滑动以显示更多选项
Listview item swipe to reveal more options
我想在 flutter 中实现这种类型的 listView
项目,但我不知道该怎么做?向左滑动时,它基本上会显示更多操作。我尝试使用水平滚动但没有按预期工作。我可以指出正确的方向吗?
首先安装这个包flutter_slidable 0.5.7
那就这么用吧,比自己动手省事多了
import 'package:flutter_slidable/flutter_slidable.dart';
Slidable(
actionPane: SlidableDrawerActionPane(),
actionExtentRatio: 0.25,
child: Container(
color: Colors.white,
child: ListTile(
leading: CircleAvatar(
backgroundColor: Colors.indigoAccent,
child: Text(''),
foregroundColor: Colors.white,
),
title: Text('Tile n°'),
subtitle: Text('SlidableDrawerDelegate'),
),
),
actions: <Widget>[
IconSlideAction(
caption: 'Edit',
color: Colors.blue,
icon: Icons.archive,
onTap: () => _showSnackBar('Archive'),
),
IconSlideAction(
caption: 'Activate',
color: Colors.indigo,
icon: Icons.share,
onTap: () => _showSnackBar('Share'),
),
],
secondaryActions: <Widget>[
IconSlideAction(
caption: 'More',
color: Colors.black45,
icon: Icons.more_horiz,
onTap: () => _showSnackBar('More'),
),
IconSlideAction(
caption: 'Delete',
color: Colors.red,
icon: Icons.delete,
onTap: () => _showSnackBar('Delete'),
),
],
);
我想在 flutter 中实现这种类型的 listView
项目,但我不知道该怎么做?向左滑动时,它基本上会显示更多操作。我尝试使用水平滚动但没有按预期工作。我可以指出正确的方向吗?
首先安装这个包flutter_slidable 0.5.7
那就这么用吧,比自己动手省事多了
import 'package:flutter_slidable/flutter_slidable.dart';
Slidable(
actionPane: SlidableDrawerActionPane(),
actionExtentRatio: 0.25,
child: Container(
color: Colors.white,
child: ListTile(
leading: CircleAvatar(
backgroundColor: Colors.indigoAccent,
child: Text(''),
foregroundColor: Colors.white,
),
title: Text('Tile n°'),
subtitle: Text('SlidableDrawerDelegate'),
),
),
actions: <Widget>[
IconSlideAction(
caption: 'Edit',
color: Colors.blue,
icon: Icons.archive,
onTap: () => _showSnackBar('Archive'),
),
IconSlideAction(
caption: 'Activate',
color: Colors.indigo,
icon: Icons.share,
onTap: () => _showSnackBar('Share'),
),
],
secondaryActions: <Widget>[
IconSlideAction(
caption: 'More',
color: Colors.black45,
icon: Icons.more_horiz,
onTap: () => _showSnackBar('More'),
),
IconSlideAction(
caption: 'Delete',
color: Colors.red,
icon: Icons.delete,
onTap: () => _showSnackBar('Delete'),
),
],
);