packages property

List<Pkg> get packages

Every package any plugin names, in declaration order, deduplicated.

Derived rather than declared. It used to be its own fw.packages([...]) call, which meant a package a plugin was configured with but the list forgot was silently dropped from that plugin — the one failure mode a declaration list exists to prevent. Reading it off the plugins cannot disagree with them.

Implementation

List<Pkg> get packages {
  var byPath = <String, Pkg>{};
  for (var plugin in plugins) {
    for (var entry in (plugin.config['packages'] as List? ?? const [])) {
      if (entry is! Map) continue;
      if (entry['path'] case String path) {
        // First mention wins, so the order is the order they are read in. The
        // plugin's own keys in this entry — `entrypoint`, `directory` — are
        // not this decoder's business and are ignored.
        byPath.putIfAbsent(
          path,
          () => Pkg.fromJson(entry.cast<String, Object?>()),
        );
      }
    }
  }
  return byPath.values.toList();
}