featureLevels function Null safety

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

Implementation

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

  /// Walk the tree and add up the children
  features.forEach((element) {
    result[element.namespace] = max(depth, result[element.namespace] ?? 0);
    featureLevels(
        features: element.dependencies, depth: depth + 1, result: result);
  });

  return result;
}