featureEdges function Null safety

Map<String, Set<String>> featureEdges(
  1. {int depth = 0,
  2. required List<DartBoardFeature> features,
  3. required Map<String, Set<String>> result}
)

Find a set of edges for each feature

Implementation

Map<String, Set<String>> featureEdges(
    {int depth = 0,
    required List<DartBoardFeature> features,
    required Map<String, Set<String>> result}) {
  if (features.isEmpty) return result;

  /// Walk the tree and add up the children
  features.forEach((element) {
    /// Add the node for edges
    if (!result.containsKey(element.namespace)) {
      result[element.namespace] = {};
    }

    result[element.namespace]
        ?.addAll(element.dependencies.map((e) => e.namespace));

    featureEdges(
        features: element.dependencies, depth: depth + 1, result: result);
  });

  return result;
}