【问题标题】:Listview item swipe to reveal more optionsListview 项目滑动以显示更多选项
【发布时间】:2021-05-03 23:25:06
【问题描述】:

我试图在颤振中实现这种类型的listView 项目,但我坚持要做什么?当向左滑动时,它基本上会显示更多动作。我尝试使用水平滚动,但没有按预期工作。我可以指出正确的方向吗?

【问题讨论】:

标签: flutter listview dart


【解决方案1】:

先安装这个包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('$3'),
        foregroundColor: Colors.white,
      ),
      title: Text('Tile n°$3'),
      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'),
    ),
  ],
);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-12
    • 2018-03-20
    • 1970-01-01
    • 2014-01-14
    • 1970-01-01
    • 1970-01-01
    • 2011-10-03
    • 1970-01-01
    相关资源
    最近更新 更多