reorderables 0.1.3+3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new68

reorderables #

pub package Donate Donate

Various reorderable Flutter widgets, including reorderable table, row, column, and wrap, that handle dragging and dropping the children within the widget. Parent widget only need to provide a function that is invoked with the old and new indexes of child being reordered.

Usage #

To use this package, add reorderables as a dependency in your pubspec.yaml file.

dependencies:
  reorderables:

And import the package in your code.

import 'package:reorderables/reorderables.dart';

Examples #

This package includes ReorderableTable, ReorderableWrap, ReorderableRow, and ReorderableColumn, which are reorderable versions of Flutter's Table, Wrap, Row, and Column respectively.

Reorderable Table #
class _TableExampleState extends State<TableExample> {
  List<ReorderableTableRow> _itemRows;

  @override
  void initState() {
    super.initState();
    var data = [
      ['Alex', 'D', 'B+', 'AA', ''],
      ['Bob', 'AAAAA+', '', 'B', ''],
      ['Cindy', '', 'To Be Confirmed', '', ''],
      ['Duke', 'C-', '', 'Failed', ''],
      ['Ellenina', 'C', 'B', 'A', 'A'],
      ['Floral', '', 'BBB', 'A', 'A'],
    ];

    Widget _textWithPadding(String text) {
      return Padding(
        padding: EdgeInsets.symmetric(vertical: 4),
        child: Text(text, textScaleFactor: 1.1),
      );
    }

    _itemRows = data.map((row) {
      return ReorderableTableRow(
        //a key must be specified for each row
        key: ObjectKey(row),
        mainAxisSize: MainAxisSize.max,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          _textWithPadding('${row[0]}'),
          _textWithPadding('${row[1]}'),
          _textWithPadding('${row[2]}'),
          _textWithPadding('${row[3]}'),
//          Text('${row[4]}'),
        ],
      );
    }).toList();
  }

  @override
  Widget build(BuildContext context) {
    var headerRow = ReorderableTableRow(
      mainAxisSize: MainAxisSize.max,
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Text('Name', textScaleFactor: 1.5),
        Text('Math', textScaleFactor: 1.5),
        Text('Science', textScaleFactor: 1.5),
        Text('Physics', textScaleFactor: 1.5),
        Text('Sports', textScaleFactor: 1.5)
      ]
    );

    void _onReorder(int oldIndex, int newIndex) {
      setState(() {
        ReorderableTableRow row = _itemRows.removeAt(oldIndex);
        _itemRows.insert(newIndex, row);
      });
    }

    return ReorderableTable(
      header: headerRow,
      children: _itemRows,
      onReorder: _onReorder,
    );
  }
}

In a table, cells in each row are aligned on column basis with cells in other rows, whereas cells in a row of a list view don't align with other rows.

Reorderable Table Demo #
Reorderable Wrap #
class _WrapExampleState extends State<WrapExample> {
  final double _iconSize = 90;
  List<Widget> _tiles;

  @override
  void initState() {
    super.initState();
    _tiles = <Widget>[
      Icon(Icons.filter_1, key: ValueKey(1), size: _iconSize),
      Icon(Icons.filter_2, key: ValueKey(2), size: _iconSize),
      Icon(Icons.filter_3, key: ValueKey(3), size: _iconSize),
      Icon(Icons.filter_4, key: ValueKey(4), size: _iconSize),
      Icon(Icons.filter_5, key: ValueKey(5), size: _iconSize),
      Icon(Icons.filter_6, key: ValueKey(6), size: _iconSize),
      Icon(Icons.filter_7, key: ValueKey(7), size: _iconSize),
      Icon(Icons.filter_8, key: ValueKey(8), size: _iconSize),
      Icon(Icons.filter_9, key: ValueKey(9), size: _iconSize),
    ];
  }

  @override
  Widget build(BuildContext context) {
    void _onReorder(int oldIndex, int newIndex) {
      setState(() {
        Widget row = _tiles.removeAt(oldIndex);
        _tiles.insert(newIndex, row);
      });
    }

    return ReorderableWrap(
      spacing: 8.0,
      runSpacing: 4.0,
      padding: const EdgeInsets.all(8),
      children: _tiles,
      onReorder: _onReorder
    );
  }
}
Reorderable Wrap Demo #

Support #

If my work has helped you, you can support me by buying me a coffee or donate me via PayPal. Your support is very much appreciated. :)

Donate or Donate

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.

example/README.md

reorderables_example #

pub package Donate Donate

Demonstrates how to use the reorderables package.

Getting Started #

This project is a starting point for using the reorderables package.

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

Demo #

Reorderable Table #
Reorderable Wrap #

Use this package as a library

1. Depend on it

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


dependencies:
  reorderables: ^0.1.3+3

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:reorderables/reorderables.dart';
  
Version Uploaded Documentation Archive
0.1.3+3 Feb 16, 2019 Go to the documentation of reorderables 0.1.3+3 Download reorderables 0.1.3+3 archive
0.1.3+2 Feb 16, 2019 Go to the documentation of reorderables 0.1.3+2 Download reorderables 0.1.3+2 archive
0.1.3 Feb 15, 2019 Go to the documentation of reorderables 0.1.3 Download reorderables 0.1.3 archive
0.1.2 Feb 13, 2019 Go to the documentation of reorderables 0.1.2 Download reorderables 0.1.2 archive
0.1.1 Feb 13, 2019 Go to the documentation of reorderables 0.1.1 Download reorderables 0.1.1 archive
0.1.0 Feb 13, 2019 Go to the documentation of reorderables 0.1.0 Download reorderables 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
35
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]
68
Learn more about scoring.

We analyzed this package on Feb 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13+1
  • Flutter: 1.2.1

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/src/rendering/tabluar_flex.dart.

Run flutter format to format lib/src/rendering/tabluar_flex.dart.

Format lib/src/rendering/transitions.dart.

Run flutter format to format lib/src/rendering/transitions.dart.

Format lib/src/rendering/wrap.dart.

Run flutter format to format lib/src/rendering/wrap.dart.

Fix additional 8 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/widgets/passthrough_overlay.dart (Run flutter format to format lib/src/widgets/passthrough_overlay.dart.)
  • lib/src/widgets/reorderable_flex.dart (Run flutter format to format lib/src/widgets/reorderable_flex.dart.)
  • lib/src/widgets/reorderable_table.dart (Run flutter format to format lib/src/widgets/reorderable_table.dart.)
  • lib/src/widgets/reorderable_wrap.dart (Run flutter format to format lib/src/widgets/reorderable_wrap.dart.)
  • lib/src/widgets/tabluar_flex.dart (Run flutter format to format lib/src/widgets/tabluar_flex.dart.)
  • lib/src/widgets/transitions.dart (Run flutter format to format lib/src/widgets/transitions.dart.)
  • lib/src/widgets/typedefs.dart (Run flutter format to format lib/src/widgets/typedefs.dart.)
  • lib/src/widgets/wrap.dart (Run flutter format to format lib/src/widgets/wrap.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test