indexTyped<Data, Tree extends IndexedTreeNode<Data>> static method

SliverTreeView<Data, Tree> indexTyped<Data, Tree extends IndexedTreeNode<Data>>({
  1. Key? key,
  2. required TreeNodeWidgetBuilder<Tree> builder,
  3. required Tree tree,
  4. ExpansionBehavior expansionBehavior = ExpansionBehavior.none,
  5. Indentation? indentation,
  6. AutoScrollController? scrollController,
  7. ExpansionIndicatorBuilder? expansionIndicatorBuilder,
  8. ValueSetter<Tree>? onItemTap,
  9. EdgeInsetsGeometry? padding,
  10. bool showRootNode = true,
  11. bool focusToNewNode = true,
  12. TreeReadyCallback<Data, Tree>? onTreeReady,
})

Use the typed constructor if you are extending the IndexedTreeNode instead of directly wrapping the data in the IndexedTreeNode. Using the SliverTreeView.indexTyped allows the builder to return the correctly typed Tree object.

This alternate implementation of SliverTreeView uses an IndexedNode internally, which is based on the List data structure for maintaining the children states. The IndexedNode allows indexed based operations like insertion and removal of items at index positions. This allows for movement, addition and removal of child nodes based on indices. The complexity for accessing child nodes in SliverTreeView.indexed is simply O(node_level ^ children).

The main advantage of using a SliverTreeView over the TreeView is that it can be easily used with others slivers in a CustomScrollView, which means that you can easily implement a fancy animated list. The slivers are lazy loaded by default, so it can be easily mixed with other widgets without any loss of performance.

The complexity for accessing child nodes in SliverTreeView.indexed is simply O(node_level ^ children).

** See code in example/lib/samples/sliver_treeview/sliver_treeview_custom_object_sample.dart **

See also:

Implementation

static SliverTreeView<Data, Tree>
    indexTyped<Data, Tree extends IndexedTreeNode<Data>>({
  Key? key,
  required TreeNodeWidgetBuilder<Tree> builder,
  required final Tree tree,
  ExpansionBehavior expansionBehavior = ExpansionBehavior.none,
  Indentation? indentation,
  AutoScrollController? scrollController,
  ExpansionIndicatorBuilder? expansionIndicatorBuilder,
  ValueSetter<Tree>? onItemTap,
  EdgeInsetsGeometry? padding,
  bool showRootNode = true,
  bool focusToNewNode = true,
  TreeReadyCallback<Data, Tree>? onTreeReady,
}) =>
        SliverTreeView._(
          key: key,
          builder: builder,
          tree: tree,
          expansionBehavior: expansionBehavior,
          indentation: indentation,
          expansionIndicatorBuilder:
              expansionIndicatorBuilder ?? _defExpansionIndicatorBuilder,
          scrollController: scrollController,
          onItemTap: onItemTap,
          padding: padding,
          showRootNode: showRootNode,
          onTreeReady: onTreeReady,
          focusToNewNode: focusToNewNode,
        );