hukusuke1007 / left-scroll-actions

Flutter的左滑删除组件

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

left_scroll_actions

A useful left scroll actions widget like WeChat.

一款仿微信效果的 Flutter 左滑菜单插件。

Example

Install

Add this to your package's pubspec.yaml file: 把如下字段加入你的pubspec.yaml文件:

dependencies:
  flutter:
    sdk: flutter
  // 添加下面这一行
  left_scroll_actions: any

然后运行flutter packages get即可

Usage

普通使用

  LeftScroll(
    buttonWidth: 80,
    child: Container(
      height: 60,
      color: Colors.white,
      alignment: Alignment.center,
      child: Text('👈 Try Scroll Left'),
    ),
    buttons: <Widget>[
      LeftScrollItem(
        text: 'delete',
        color: Colors.red,
        onTap: () {
          print('delete');
        },
      ),
    ],
    onTap: () {
      print('tap row');
    },
  );

左滑列表(1.2.0新增):,如果你打开一行,其他行会自动关闭

LeftScrollList.builder(
  count: list.length,
  builder: (ctx, index) => LeftScrollListItem(
      key: list[index],
      child: Container(
        height: 60,
        padding: EdgeInsets.only(left: 20),
        color: Colors.white,
        alignment: Alignment.centerLeft,
        child: Text('(${list[index]})Scroll Left To Delete'),
      ),
      buttons: [
        LeftScrollItem(
          text: 'delete',
          color: Colors.red,
          onTap: () {
            print('delete');
            if (list.contains(list[index])) {
              list.remove(list[index]);
              setState(() {});
            }
          },
        ),
      ],
      onTap: () {
        print('tap row');
        list.add((Random().nextDouble() * 10000000 ~/ 1).toString());
        setState(() {});
      },
  );
);

See:

Example

Example

Getting Started

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

About

Flutter的左滑删除组件

License:Other


Languages

Language:Dart 94.7%Language:Objective-C 2.4%Language:Shell 1.7%Language:Java 1.2%