Giter VIP home page Giter VIP logo

flutter_slidable's Introduction

flutter_slidable

A Flutter implementation of slidable list item with left and right slide actions.

Pub Donate

Overview

Features

  • Accepts left and right widget lists as slide actions.
  • 4 built-in layouts.
  • 2 built-in slide action widget.
  • You can easily create you custom layouts and animations.
  • You can use a builder to create your slide actions if you want special effects during animation.
  • Close when a slide action has been tapped (overridable).
  • Close when the nearest Scrollable starts to scroll (overridable).

Getting started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  flutter_slidable: "^0.3.0"

In your library add the following import:

import 'package:flutter_slidable/flutter_slidable.dart';

For help getting started with Flutter, view the online documentation.

Constructors

You can create a Slidable in two different ways:

  • By calling the Slidable constructor and passing a list of slide actions.
  • By calling the Slidable.builder constructor and passing slide action builders, if you want special effects during the animation.

A Slidable needs multiple things:

  • Slide actions (see below for details). Which can be any widget. For convenience this package has 2 built-in side action widgets.
  • A delegate. This is what controls the layout and the animation of the slide menu.
  • An extent ratio between a slide action extent and the item extent.
  • A child.

The actions contains the slide actions that appears when the child has been dragged down or to the right. The secondaryActions contains the slide actions that appears when the child has been dragged up or to the left.

A direction parameter let you choose if you want actions to appear when you slide horizontally or vertically (horizontally by default).

new Slidable(
  delegate: new SlidableDrawerDelegate(),
  actionExtentRatio: 0.25,
  child: new Container(
    color: Colors.white,
    child: new ListTile(
      leading: new CircleAvatar(
        backgroundColor: Colors.indigoAccent,
        child: new Text('$3'),
        foregroundColor: Colors.white,
      ),
      title: new Text('Tile n°$3'),
      subtitle: new Text('SlidableDrawerDelegate'),
    ),
  ),
  actions: <Widget>[
    new IconSlideAction(
      caption: 'Archive',
      color: Colors.blue,
      icon: Icons.archive,
      onTap: () => _showSnackBar('Archive'),
    ),
    new IconSlideAction(
      caption: 'Share',
      color: Colors.indigo,
      icon: Icons.share,
      onTap: () => _showSnackBar('Share'),
    ),
  ],
  secondaryActions: <Widget>[
    new IconSlideAction(
      caption: 'More',
      color: Colors.black45,
      icon: Icons.more_horiz,
      onTap: () => _showSnackBar('More'),
    ),
    new IconSlideAction(
      caption: 'Delete',
      color: Colors.red,
      icon: Icons.delete,
      onTap: () => _showSnackBar('Delete'),
    ),
  ],
);

Built-in slide actions

This package comes with 2 kind of slide actions:

  • SlideAction which the more permissive. You can choose a background color, or any decoration, and it takes any widget as a child.
  • IconSlideAction which requires an icon, and cake have a background color and a caption below the icon.

Built-in delegates

This package comes with 4 kind of delegates:

SlidableBehindDelegate

The slide actions stay behind the item while it's sliding:

Overview

SlidableScrollDelegate

The slide actions follow the item while it's sliding:

Overview

SlidableDrawerDelegate

The slide actions which animate like drawers while the item is sliding:

Overview

SlidableStrechDelegate

The slide actions stretch while the item is sliding:

Overview

How to prevent my slide action to close after it has been tapped?

By default, SlideAction and IconSlideAction close on tap. To prevent this, you can set false to the closeOnTap constructor argument.

How to prevent my Slidable to close after my list scrolled?

By default, a Slidable closes when the nearest Scrollable widget starts to scroll. To prevent this, you can set false to the closeOnScroll constructor argument.

Changelog

Please see the Changelog page to know what's recently changed.

Contributions

Feel free to contribute to this project.

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue.
If you fixed a bug or implemented a new feature, please send a pull request.

flutter_slidable's People

Contributors

letsar avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.