tree_view_package 1.0.2
tree_view_package: ^1.0.2 copied to clipboard
A powerful and flexible tree view package for Flutter with drag-and-drop, animations, and customizable indentation guides.
My Tree View Package #
A powerful and flexible Flutter package for displaying hierarchical data in tree structures.
Features #
- π³ Dynamic Tree Rendering - Works with any data structure
- π¨ Customizable Indentation - Multiple guide styles (connecting lines, scoping lines, blank)
- β¨ Smooth Animations - Animated expand/collapse transitions
- βοΈ Checkbox Selection - Multi-select with Select All/Unselect All support
- π― Drag & Drop Support - Full drag and drop functionality with auto-scroll
- π High Performance - Lazy rendering with slivers
- π Search Functionality - Built-in tree search with direct/indirect matching
- π¦ Generic Type Support - Works with any node type
- πͺ Dropdown Support - Tree structure in dropdown form with multi-select
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
my_tree_view_package: ^1.0.0
Quick Start #
import 'package:flutter/material.dart';
import 'package:my_tree_view_package/my_tree_view_package.dart';
class MyNode {
const MyNode({required this.title, this.children = const []});
final String title;
final List<MyNode> children;
}
class MyTreeView extends StatefulWidget {
@override
State<MyTreeView> createState() => _MyTreeViewState();
}
class _MyTreeViewState extends State<MyTreeView> {
late final TreeController<MyNode> treeController;
@override
void initState() {
super.initState();
treeController = TreeController<MyNode>(
roots: [
MyNode(title: 'Root', children: [
MyNode(title: 'Child 1'),
MyNode(title: 'Child 2'),
]),
],
childrenProvider: (node) => node.children,
);
}
@override
void dispose() {
treeController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return TreeView<MyNode>(
treeController: treeController,
nodeBuilder: (context, entry) {
return ListTile(
title: Text(entry.node.title),
onTap: () => treeController.toggleExpansion(entry.node),
);
},
);
}
}
Documentation #
See the example directory for comprehensive usage examples.
License #
MIT License