directory_tree 2.0.0
directory_tree: ^2.0.0 copied to clipboard
Deterministic, immutable directory trees for pure Dart: canonical paths, indexed nodes, flattened rows, filters, selection, and diffs on every platform.
Changelog #
All notable changes to this project will be documented in this file.
2.0.0 #
2.0.0 is a rewrite with a new API, and code written for 1.x does not compile
against it. MIGRATION.md maps every 1.x declaration to its
replacement and lists the behavior changes. dart fix --apply renames
ListDiff.removeIndicesDesc, ListDiff.insertIndicesAsc, and
TreeEntry.fullPath; every other change is manual.
Breaking changes #
TreeBuilder,TreeData, and the mutableTreeNodemap are replaced by an immutable, indexedDirectoryTree<T>. Build it withDirectoryTree.build,DirectoryTree.fromPaths, orDirectoryTreeBuilder, and configure it withTreeOptions.TreeEntryis nowTreeEntry.file(path, data: ...)orTreeEntry.directory(path, data: ...), andmetadatais now typeddata. Entry ids, names,isVirtual, virtual entries, andvirtualParentare removed.- Node ids are
NodeIds holding the canonical path instead of generatednode_...andfolder_...strings. The syntheticrootandtree_rootnodes, visible-root hoisting,NodeType, andSelectionOriginare removed. Nodes are a sealedTreeNodewithFileNodeandDirectoryNode. - Paths are case sensitive by default. Use
PathPolicy.caseInsensitivefor the 1.x behavior. FlattenStrategy,DefaultFlattenStrategy,SortedFlattenStrategy,SortDelegate,AlphaSortDelegate, andVisibleNodeare replaced byDirectoryTree.flatten,TreeRows,TreeRow, andTreeOptions.order. Siblings sort directories first, in natural order (file2beforefile10).diffVisibleNodesis replaced byListDiff.compute, which diffs any keyed list and reports kept rows whose content changed inchangedIndices. Keys must be unique: a repeat in the part of the lists that differs throws anArgumentError, and repeats elsewhere are caught when assertions are enabled.compileFilterandPredicateare replaced byTreeQueryandTreeFilter. Queries add glob, path, quoted,type:, andpath:terms, andext:no longer matches directories.ExpansionSetandSelectionSetare replaced by the immutableExpansionStateandSelectionState.SelectionMode.multiis nowSelectionMode.multiple, and toggling the selected id in single mode now clears it.folderSelectionandFolderSelectionare replaced bySelectionState.checkStateOfandCheckState, which count empty directories as leaves.basename,extensionLower,hasAnyExtension,ancestorChain, andfindByVirtualPathare removed. UseTreePath,DirectoryTree.ancestorsOf, andDirectoryTree.nodeAt.- Bad input is skipped and reported in
DirectoryTree.issuesinstead of being normalized or dropped silently: unparseable paths, relative paths that climb above their root, files that other entries lie inside, and entries outside fixed roots. When two entries share a path, the later one wins.
Added #
TreePathandPathPolicy: platform-independent parsing of POSIX, Windows drive, and UNC paths (including their\\?\spellings), with optional case folding and Unicode normalization. Case-insensitive ids,TreeQuery, andTreeOrder.compareNamesfold case with the package's own Unicode simple case folding table (Unicode 18.0.0), so results are identical on the VM, JavaScript, and WebAssembly.TreeRoots: minimal, common-ancestor, fixed, and file-system strategies for choosing the top-level nodes.TreeRowsupdates rows incrementally withexpandNode,collapseNode,toggleNode, andreveal, supports compact folders and hidden roots, and offers row lookup for keyboard navigation.requestedExpansiongives the state to persist without the folders a search opened.TreeRowcarriesisExpanded,isLast,guides,isMatch, and thechainof a compacted row.DirectoryTree.renderandTreeStyleprint a tree like thetreecommand, escaping control characters in names so each row stays on one line.TreeDifflists the nodes added, removed, and changed between two trees.ExpansionStateandSelectionStateround-trip through JSON.SelectionStatekeeps a range anchor and adds tri-state checks (check,uncheck,toggleCheck,canCheck,checkStates).TreeQuery.matchRangesreturns the ranges of a label to highlight.package:directory_tree/io.dartaddsDirectoryScanner, which lists a directory on disk as entries, on Windows also pastMAX_PATH. It needsdart:io; the core library does not import it.
Compatibility #
- The minimum Dart SDK is now 3.8.0 (1.0.0 required 3.10.4).
- The
equatable,path, anduuiddependencies are removed. The package depends only onmeta.
1.0.0 - 2026-01-02 #
Initial Release #
- Core
TreeBuilderfor normalizing paths and generating deterministic tree structures. TreeDataandTreeNodeimmutable models.FlattenStrategy(DFS) andSortedFlattenStrategyfor linearizing trees.diffVisibleNodesusing Longest Increasing Subsequence (LIS) for efficient list updates.ExpansionSetandSelectionSetstate helpers.compileFilterfor flexible text and extension searching.- Cross-platform path normalization (Windows/POSIX).