drag_list 1.0.8

  • Readme
  • Changelog
  • Example
  • Installing
  • 91

DragList #

pub package

Flutter list widget that allows to drag and drop items and define custom drag handle widget.

DragList demo

Getting Started #

Add DragList component to your widget tree:

child: DragList<String>(
  items: ['Tuna', 'Meat', 'Cheese', 'Potato', 'Eggs', 'Bread'],
  itemExtent: 72.0,
  builder: (context, item, handle) {
    return Container(
      height: 72.0,
      child: Row(children: [
        Spacer(),
        Text(item),
        Spacer(),
        handle,
      ]),
    );
  },
),

Optionally, provide custom handle builder:

child: DragList<String>(
  // ...
  handleBuilder: (context) {
    return Padding(
      padding: EdgeInsets.all(16.0),
      child: Container(
        color: Colors.green,
        child: Text('Handle'),
      ),
    );
  },
),

Add other optional parameter if needed:

child: DragList<String>(
  // ...
  animDuration: Duration(milliseconds: 500),
  dragDelay: Duration(seconds: 1),
  handleAlignment: -0.3,
  scrollDirection: Axis.horizontal,
  onItemReorder: (from, to) {
    // handle item reorder on your own
  },
),

Use handleless constructor if you want list item to be dragged no matter where it's tapped on:

DragList<String>.handleless(
  // ...
  builder: (context, item) {
    return Container(
      height: 72.0,
      child: Center(child: Text(item)),
    );
  },
),

[1.0.8] - 27/04/2020 #

  • Added DragItem that provides index values in builders

[1.0.7] - 13/02/2020 #

  • Added feedback widget builders

[1.0.6] - 06/01/2020 #

  • Added auto scroll when dragging an item feature

[1.0.4] - 01/10/2019 #

  • Added scrollPhysics property

[1.0.3] - 25/06/2019 #

  • Added padding property

[1.0.2] - 22/06/2019 #

  • Added controller property

[1.0.1] - 25/05/2019 #

  • Added shrinkWrap property

[1.0.0] - 20/03/2019 #

  • Implemented core functionality

example/main.dart

import 'package:drag_list/drag_list.dart';
import 'package:flutter/material.dart';

void main() => runApp(CountriesPage());

class CountriesPage extends StatelessWidget {
  final _itemHeight = 72.0;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'DragList example',
      home: Scaffold(
        appBar: AppBar(title: Text('Largest countries')),
        body: Padding(
          padding: EdgeInsets.all(16.0),
          child: DragList<String>(
            items: _countries,
            itemExtent: _itemHeight,
            handleBuilder: (_) => AnimatedIcon(
              icon: AnimatedIcons.menu_arrow,
              progress: AlwaysStoppedAnimation(0.0),
            ),
            feedbackHandleBuilder: (_, transition) => AnimatedIcon(
              icon: AnimatedIcons.menu_arrow,
              progress: transition,
            ),
            itemBuilder: (_, item, handle) => Container(
              height: _itemHeight,
              child: Padding(
                padding: EdgeInsets.all(8.0),
                child: Row(children: [
                  Expanded(child: Center(child: Text(item.value))),
                  handle,
                ]),
              ),
            ),
          ),
        ),
      ),
    );
  }

  final _countries = [
    'Russia',
    'China',
    'United States',
    'Canada',
    'Brazil',
    'Australia',
    'India',
    'Argentina',
    'Kazakhstan',
    'Algeria',
    'DR Congo',
    'Saudi',
    'Mexico',
    'Indonesia',
    'Sudan',
    'Libya',
    'Iran',
    'Mongolia',
    'Peru',
    'Niger',
  ];
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  drag_list: ^1.0.8

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:drag_list/drag_list.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
83
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
91
Learn more about scoring.

We analyzed this package on Jul 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • drag_list that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
async ^2.0.8 2.4.2
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test