dynamic_treeview 1.0.0+2
dynamic_treeview: ^1.0.0+2 copied to clipboard
A Dynamic treeview that can be build using dynamic parent/child relationship. It supports indefinite category/subcategory lists with horizontal and vertical scrolling
dynamic_treeview - A flutter package #
A Dynamic treeview that can be build using dynamic parent/child relationship. It supports indefinite category/subcategory lists with horizontal and vertical scrolling
Getting Started #
In your flutter project add the dependency:
dependencies:
...
dynamic_treeview: 1.0.0+2
copied to clipboard
Import package #
import 'package:dynamic_treeview/dynamic_treeview.dart';
copied to clipboard
BaseModel implementation #
Since DynamicTreeView is build using data having parent/child relationship,
you must create a class model that implements BaseModel and overrides the method
like getParentId(), getId() and getTitle() and return appropriate values to make it work.
The method getExtraData() has also been added just in-case if any extra data is needed when child/parent is tapped.
copied to clipboard
Sample Usage #
DynamicTreeView(
data: getData(), // pass here List<BaseModel>
config: Config(
parentTextStyle:
TextStyle(color: Colors.black, fontWeight: FontWeight.w600),
rootId: "1",
parentPaddingEdgeInsets:
EdgeInsets.only(left: 16, top: 0, bottom: 0)),
onTap: (m) {
//action on tap
},
width: MediaQuery.of(context).size.width,
)
copied to clipboard
Constructor parameters #
data - List<BaseData> .TreeView will be build based on this data.This is a required field
config - Various Configuration options
onTap - Callback when tapped on parent/child widget
copied to clipboard
Configuration parameters #
parentTextStyle - Parent tile TextStyle
parentPaddingEdgeInsets - Parent tile padding
childrenTextStyle - Child tile TextStyle
childrenPaddingEdgeInsets - Children tile padding
copied to clipboard
Check the Config class in dynamic_treeview.dart file for details.
Sample code #
Please check example for details.