recursive_tree_flutter 0.0.1 copy "recursive_tree_flutter: ^0.0.1" to clipboard
recursive_tree_flutter: ^0.0.1 copied to clipboard

A tree-view package which focuses on tree data structure and displays it into UI.

recursive_tree_flutter #

Thư viện recursive_tree_flutter giúp xây dựng một cấu trúc dữ liệu kiểu cây và trực quan hoá chúng dưới dạng cây kế thừa (stack view hoặc expandable tree view). Đa số các thư viện tree-view tập trung vào giao diện, nhưng recursive_tree_flutter sẽ tập trung vào cấu trúc dữ liệu cây nên sẽ có thể đáp ứng được nhiều kiểu UI đặc biệt hơn - đó chính là điểm mạnh của thư viện này. Chẳng hạn như khả năng update cây khi một node được chọn.

Mục lục #

Tính năng #

Một số tính năng mà thư viện này cung cấp:

  • Tạo một cấu trúc dữ liệu kiểu cây (Dart code).
  • Nhiều function thao tác trên cây, ví dụ như find node, search with text, update cây multiple choice...
  • Cho phép mở rộng cây trong run-time (lazy-loading).
  • Có thể sử dụng riêng cấu trúc dữ liệu cây tách biệt hoàn toàn với Flutter UI.
  • Trực quan hoá cấu trúc cây bằng Flutter.
  • Cho phép tuỳ chỉnh giao diện Flutter để phù hợp với nhu cầu sử dụng.

Nội dung #

Cấu trúc dữ liệu cây (Dart code) #

Được lấy ý tưởng từ cấu trúc của một cây thư mục trong máy tính, ta sẽ có 2 loại: thư mục và tệp. Một thư mục có thể chứa nhiều tệp và thư mục khác, và tệp là cấp độ bé nhất không thể chứa thêm gì nữa.

Tương tự cấu trúc cây thư mục trong máy tính, recursive_tree_flutter sẽ xây dựng một cấu trúc dữ liệu cây bao gồm inner node và leaf node.

  • AbsNodeType: Class trừu tượng cho kiểu dữ liệu của một node. Một node có thể là inner node và leaf node. Class này có các thuộc tính sau:
    • id: required, dynamic.
      • title: required, String.
      • isInner: boolean, mặc định là true.
      • isUnavailable: boolean, mặc định là false.
      • isChosen: nullable boolean, mặc định là false.
      • isExpanded: boolean, mặc định là false.
      • isFavorite: nullable boolean.
      • clone(): override, T extends AbsNodeType. Cho phép clone object.
  • TreeType: Cấu trúc dữ liệu cây.
    • T là Implement Class của AbsNodeType.
      • data: required, T. Dữ liệu (nội dung) trong node gốc của cây hiện tại.
      • children: required, List<TreeType<T>>. Danh sách những cây con.
      • parent: required, TreeType<T>?. Cha của cây hiện tại. Nếu parent == null, tức là ta đang ở root của toàn bộ cây.
      • isChildrenLoadedLazily: boolean, mặc định là false. Chỉ được sử dụng nếu cây hiện tại là lazy-loading, cho biết liệu children đã được load lần nào hay chưa.
      • isLeaf: Cây hiện tại đang ở node lá?
      • isRoot: Cây hiện tại đang ở node root?
      • clone(tree, parent): static method. Cho phép clone một cây.

Hàm phụ trợ (Dart code) #

Cây giao diện Flutter #

StackWidget: Cây giao diện được xây dựng theo kiểu stack. Multiple choice, data được parse 1 lần duy nhất:

Demo 1

StackWidget: Cây giao diện được xây dựng theo kiểu stack lazy-loading. Multiple choice, data được parse run-time:

Demo 2

ExpandableTreeWidget: Cây giao diện được xây dựng theo kiểu expandable, data được parse 1 lần duy nhất:

Demo 3

VTSDepartmentTreeWidget: Một cây giao diện khác được xây dựng theo kiểu expandable, data được parse 1 lần duy nhất:

Demo 4

BSD 3-Clause License #

Copyright (c) 2023, Nguyễn Văn Biên

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
   contributors may be used to endorse or promote products derived from
   this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

NOTE: Hoàng Sa, Trường Sa là của Việt Nam.

29
likes
0
pub points
79%
popularity

Publisher

unverified uploader

A tree-view package which focuses on tree data structure and displays it into UI.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on recursive_tree_flutter