fromFlat<T> static method

List<Tree<T>> fromFlat<T>(
  1. List<T> flatItems,
  2. int? parentKey(
    1. T node
    ),
  3. int getKey(
    1. T node
    )
)

Implementation

static List<Tree<T>> fromFlat<T>(List<T> flatItems, int? Function(T node) parentKey, int Function(T node) getKey) {
  // ignore: prefer_for_elements_to_map_fromiterable
  var _lookUp = Map<int, Tree<T>>.fromIterable(
    flatItems,
    key: (object) => getKey(object),
    value: (object) => Tree(value: object),
  );
  return _generateTree<T>(_lookUp, parentKey, getKey, flatItems);
}