Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

listtreeview

a tree,view for flutter based on the listview.

  • highly customizable. it only manages the tree structure of the data, and the ui is designed by yourself.
  • performance is efficient because of the listview’s reuse mechanism.
  • infinitely increasing child levels and child nodes

listtreeview

getting started

installation

1. depend on it
dependencies:
  list_tre,eview: [version]
2. install it
$ flutter pub get

3. import it
import 'package:list_tre,eview/list_treeview.dart';

usage

1、initialize controller.

the controller must be initialized when the treeview create

class _treepagestate extends state<treepage> {
  treeviewcontroller _controller;
  @override
  void initstate() {
    super.initstate();
    ///the controller must be initialized when the treeview create
    _controller = treeviewcontroller();
  }
}

2、set the data for each row.

  • your data class must inherit from nodedata, and you can customize other properties of the class.
/// the data class that is bound to the child node
/// you must inherit from nodedata !!!
/// you can customize any of your properties
class treenodedata extends nodedata {
  treenodedata({this.label,this.color}) : super();

  /// other properties that you want to define
  final string label;
  final color color;
  string property1;
  string property2;
  string property3;
  ///...
}
  • set the treeview’s data, use ‘_controller.treedata()’
void getdata() async {
    print('start get data');
    _issuccess = false;
    await future.delayed(duration(seconds: 2));

    var colors1 = treenodedata(label: 'colors1');
    var color11 = treenodedata(
        label: 'rgb(0,139,69)', color: color.fromargb(255, 0, 139, 69));
    var color12 = treenodedata(
        label: 'rgb(0,139,69)', color: color.fromargb(255, 0, 191, 255));
    var color13 = treenodedata(
        label: 'rgb(0,139,69)', color: color.fromargb(255, 255, 106, 106));
    var color14 = treenodedata(
        label: 'rgb(0,139,69)', color: color.fromargb(255, 160, 32, 240));
    colors1.addchild(color11);
    colors1.addchild(color12);
    colors1.addchild(color13);
    colors1.addchild(color14);

    var colors2 = treenodedata(label: 'colors2');
    var color21 = treenodedata(
        label: 'rgb(0,139,69)', color: color.fromargb(255, 255, 64, 64));
    var color22 = treenodedata(
        label: 'rgb(0,139,69)', color: color.fromargb(255, 28, 134, 238));
    var color23 = treenodedata(
        label: 'rgb(0,139,69)', color: color.fromargb(255, 255, 106, 106));
    var color24 = treenodedata(
        label: 'rgb(0,139,69)', color: color.fromargb(255, 205, 198, 115));
    colors2.addchild(color21);
    colors2.addchild(color22);
    colors2.addchild(color23);
    colors2.addchild(color24);

    /// set data
    _controller.treedata([colors1, colors2]);
    print('set treedata suceess');

    setstate(() {
      _issuccess = true;
    });

  }

insert

_controller.insertatfront(datanode,newnode);
//_controller.insertatrear(datanode, newnode);
//_controller.insertatindex(1, datanode, newnode);

remove

_controller.removeitem(item);

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.