搜索插件、代码仓与 APP 分类

插件详情v1.0.0+2

dynamic_treeview

一个动态树形视图,可以通过动态的父子关系构建。它支持无限层级的分类/子分类列表,并支持水平和垂直滚动。

近 30 天下载
7
喜欢数
47
Pub 分数
40

安装插件

flutter pub add dynamic_treeview

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个用于创建动态、交互式树形视图的 Flutter 包,支持灵活的父子关系。它可构建无限层级的分类和子分类结构,支持横向和纵向滚动以处理大型数据集。非常适合组织嵌套数据结构,如文件系统、组织架构图或产品类别。树形视图能动态适应数据变化,确保流畅性能和可扩展性。

适合场景

  • 组织架构图
  • 文件系统导航
  • 产品类别树
  • 嵌套数据展示
  • 动态筛选界面

主要特点

  • 支持无限嵌套层级
  • 水平和垂直滚动支持
  • 动态数据绑定
  • 可自定义节点样式
  • 高效渲染大型数据集

适合对象

  • 具有层级数据的应用程序
  • 需要可展开列表的复杂UI
  • 数据密集型应用
  • 自定义树状导航
  • 可扩展的 UI 组件

使用建议

  • 需要仔细的状态管理
  • 深度过大的树可能导致性能下降
  • 有限的平台特定优化
  • 无内置的搜索/筛选功能
  • 需要自定义动画实现

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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

Import package

import 'package:dynamic_treeview/dynamic_treeview.dart';

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.

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,
    )

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

Configuration parameters

    parentTextStyle                 -   Parent tile TextStyle
    parentPaddingEdgeInsets         -   Parent tile padding
    childrenTextStyle               -   Child tile TextStyle
    childrenPaddingEdgeInsets       -   Children tile padding

Check the Config class in dynamic_treeview.dart file for details.

Sample code

Please check example for details.

Screenshots

Full Screen

alt text

Drawer

alt text

MIT LICENSE
I spent weeks of my time developing this package. I really hope this saves you loads of time and i'd be glad to hear your feedback.Let me know if you find any bugs/issues.Thanks.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。