File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,3 +116,13 @@ extension TextInputFormatterModelIterableExt<T extends TextInputFormatterModel>
116116 return model;
117117 }
118118}
119+
120+ /// A helper extension that adds additional functionality to [List] .
121+ extension ListExt <T > on List <T > {
122+ /// Removes all the items in the [items] list from this list.
123+ void removeAll (Iterable <T > items) {
124+ for (final item in items) {
125+ remove (item);
126+ }
127+ }
128+ }
Original file line number Diff line number Diff line change @@ -95,3 +95,15 @@ String resolveParentNodeIDs({
9595 )? .id ??
9696 kRootNode;
9797}
98+
99+ /// Returns the top-most parent ID of the given [nodes] map.
100+ /// Where [nodes] map is a map of node IDs to their respective node JSON.
101+ List <String > getTopMostParentIDs (Map <String , dynamic > nodes) {
102+ List <String > parentIds = nodes.keys.toList ();
103+ for (final Map <String , dynamic > node in nodes.values) {
104+ if (node.containsKey ('children' )) {
105+ parentIds.removeAll (List <String >.from (node['children' ]));
106+ }
107+ }
108+ return parentIds;
109+ }
You can’t perform that action at this time.
0 commit comments