flutter_list_drag_and_drop 0.1.5

  • README.md
  • Example
  • Installing
  • Versions
  • 89

flutter_list_drag_and_drop

The Flutter team has also pushed this feature to the framework, https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/material/reorderable_list.dart

A new Flutter package which handles all aspects of drag and drop inside a listView.

In your pubspec.yaml

dependencies:
  flutter_list_drag_and_drop: "^0.1.3"

Demo

Demo 1

Features

  • When dragging an item to the top/ bottom the list scroll accordingly
  • Works with different sized items
  • material like behaviour

Take a look at the example folder for info on how to use

If you encounter feel free to open an issue. Pull request are also welcome.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_list_drag_and_drop/drag_and_drop_list.dart';

void main() {
  runApp(new TestApp());
}

class TestApp extends StatelessWidget {
  TestApp({Key key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
          primarySwatch: Colors.blue, primaryColor: new Color(0xffd05c6b)),
      home: new MyHomePage(
        title: 'Flutter Demo Home Page',
        key: key,
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  MyHomePageState createState() => new MyHomePageState();
}

class MyHomePageState extends State<MyHomePage> {
  List<String> items = [
    '0',
    '1',
    '2',
    '3',
    '4',
    '5',
    '6',
    '7',
    '8',
    '9',
    '10',
    '11',
    '12',
    '13',
    '14',
    '15',
  ];
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new DragAndDropList<String>(
        items,
        itemBuilder: (BuildContext context, item) {
          return new SizedBox(
            child: new Card(
              child: new ListTile(
                title: new Text(item),
              ),
            ),
          );
        },
        onDragFinish: (before, after) {
          String data = items[before];
          items.removeAt(before);
          items.insert(after, data);
        },
        canBeDraggedTo: (one, two) => true,
        dragElevation: 8.0,
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_list_drag_and_drop: ^0.1.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_list_drag_and_drop/drag_and_drop_list.dart';
import 'package:flutter_list_drag_and_drop/my_draggable.dart';
  
Version Uploaded Documentation Archive
0.1.5 Aug 31, 2018 Go to the documentation of flutter_list_drag_and_drop 0.1.5 Download flutter_list_drag_and_drop 0.1.5 archive
0.1.4 Aug 6, 2018 Go to the documentation of flutter_list_drag_and_drop 0.1.4 Download flutter_list_drag_and_drop 0.1.4 archive
0.1.3 May 7, 2018 Go to the documentation of flutter_list_drag_and_drop 0.1.3 Download flutter_list_drag_and_drop 0.1.3 archive
0.1.2 May 1, 2018 Go to the documentation of flutter_list_drag_and_drop 0.1.2 Download flutter_list_drag_and_drop 0.1.2 archive
0.1.1 Apr 26, 2018 Go to the documentation of flutter_list_drag_and_drop 0.1.1 Download flutter_list_drag_and_drop 0.1.1 archive
0.1.0 Apr 26, 2018 Go to the documentation of flutter_list_drag_and_drop 0.1.0 Download flutter_list_drag_and_drop 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
87
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

We analyzed this package on Sep 18, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.3
  • Flutter: 0.8.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Issues and suggestions

Maintain CHANGELOG.md.

Changelog entries help clients to follow the progress in your code.

Fix lib/drag_and_drop_list.dart.

Analysis of lib/drag_and_drop_list.dart reported 3 hints:

line 196 col 16: The value of the local variable 'end' isn't used.

line 339 col 7: This class inherits from a class marked as @immutable, and therefore should be immutable (all instance fields must be final).

line 343 col 16: The value of the field '_kScrollThreashhold' isn't used.

Format lib/my_draggable.dart.

Run flutter format to format lib/my_draggable.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
cupertino_icons ^0.1.0 0.1.2
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test