GithubHelp home page GithubHelp logo

raflisusanto / reorderable_tree Goto Github PK

View Code? Open in Web Editor NEW

This project forked from novade/flutter_packages

0.0 0.0 0.0 1.6 MB

License: BSD 3-Clause "New" or "Revised" License

Objective-C 0.05% Kotlin 0.17% Dart 92.86% Swift 1.60% HTML 5.32%

reorderable_tree's Introduction

codecov

Expandable Reorderable List

A wrapper around ReorderableListView that allows you to:

  • Display a tree of items.
  • Expand and collapse them.
  • Reorder them.

Checkout our example:

Example

This example, inspired by the ReorderableListView documentation, creates a list using ExpandableReorderableList:

class MyList extends StatefulWidget {
  const MyList({Key? key}) : super(key: key);

  @override
  _MyListState createState() => _MyListState();
}

class _MyListState extends State<HomeTest> {
  final List<int> _items = List<int>.generate(50, (index) => index);

  @override
  Widget build(BuildContext context) {
    final colorScheme = Theme.of(context).colorScheme;
    final oddItemColor = colorScheme.primary.withOpacity(0.05);
    final evenItemColor = colorScheme.primary.withOpacity(0.15);
    return ExpandableReorderableList<ValueKey<int>>(
      onReorder: (onReorderParam) {
        setState(() {
          var newIndex = onReorderParam.newIndex;
          if (onReorderParam.oldIndex < onReorderParam.newIndex) {
            newIndex -= 1;
          }
          final int item = _items.removeAt(onReorderParam.oldIndex);
          _items.insert(newIndex, item);
        });
      },
      children: _items.map((int item) {
        return ExpandableReorderableListItem<ValueKey<int>>(
          key: ValueKey<int>(item),
          builder: (_, child, model) {
            return ReorderableDragStartListener(
              index: model.index!,
              child: ListTile(
                title: Text('Item $item'),
                tileColor: item.isOdd ? oddItemColor : evenItemColor,
              ),
            );
          },
        );
      }).toList(),
    );
  }
}

reorderable_tree's People

Contributors

valentinvignal avatar gp4ck avatar raflisusanto 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.