createTaskMap function

Map<String, TaskWithDeps> createTaskMap(
  1. Iterable<Task> tasks
)

Create a Map from the name of a task to the corresponding TaskWithDeps.

The transitive dependencies of a task are resolved, so that each returned TaskWithDeps knows every dependency it has, not only their directly declared dependencies.

Implementation

Map<String, TaskWithDeps> createTaskMap(Iterable<Task> tasks) {
  final tasksByName = tasks
      .toList(growable: false)
      .asMap()
      .map((_, task) => MapEntry(task.name, task));
  final result = <String, TaskWithDeps>{};
  tasksByName.forEach((name, _) {
    _collectTransitiveDependencies(name, tasksByName, result, {}, '');
  });
  return result;
}