checklist 0.1.4

Flutter Android iOS web

A reordable checklist in flutter

pub package

Flutter ChecklistView #

Getting Started #

This package is a custom view that allows you to be able to re-order items in a list vertically. You can drag between lists, use it in a ScrollController (ListView,Column etc) and show and hide lists. To show Checkboxes pass in value to ChecklistItemView.

Example

Example #

  List<ChecklistObject> items = [];

  @override
  void initState() {
    super.initState();
    items.add(ChecklistObject(title: "Title 1",items: []));
    items.add(ChecklistObject(title: "Title 2",items: [
      ChecklistItemObject(title: "Item 1"),
      ChecklistItemObject(title: "Item 2"),
      ChecklistItemObject(title: "Item 3"),
      ChecklistItemObject(title: "Item 4")
    ]));
  }

  @override
  Widget build(BuildContext context) {
    List<ChecklistView> checklistsViews = new List();
    for (var i = 0; i < items.length; i++) {
      List<ChecklistItemView> subItems = new List();
      for(var j = 0; j < items[i].items.length;j++){
        subItems.add(ChecklistItemView(title: Card(child: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Text(items[i].items[j].title),
        )),
        canDrag:true,
        onDropItem: (oldListIndex,oldItemIndex,listIndex, itemIndex, state){
          //Update our local data
          setState(() {
            ChecklistItemObject object = items[oldListIndex].items[oldItemIndex];
            items[oldListIndex].items.removeAt(oldItemIndex);
            items[listIndex].items.insert(itemIndex, object);
          });
        },));
      }
      checklistsViews.add(ChecklistView(items: subItems,isOpen: items[i].isOpen,canDrag:true,onDropChecklist:(oldIndex,newIndex,state){
        //Update our local data
        setState(() {          
          ChecklistObject object = items[oldIndex];
          items.removeAt(oldIndex);
          items.insert(newIndex, object);
        });
      },title: Row(children: <Widget>[IconButton(icon: Icon(items[i].isOpen?Icons.arrow_drop_up:Icons.arrow_drop_down),onPressed: (){
        setState(() {
          items[i].isOpen = !items[i].isOpen;
        });
      },),Expanded(child: Text(items[i].title))],),));
    }
    return Scaffold(
      appBar: AppBar(),
        body: ChecklistListView(checklists: checklistsViews)
    );
  }
3
likes
70
pub points
51%
popularity

A reordable checklist in flutter

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

jakebonk@gmail.com

License

BSD (LICENSE)

Dependencies

flutter

More

Packages that depend on checklist