casesOfModule method

List<ContractCase> casesOfModule(
  1. ModuleId id
)

The cases of the module id:

  • every provider of the role of its variants, including a provider the module has no variant for, whose app the pipeline rejects;
  • every provider of each role the module requires that has several;
  • each subset of the roles the module only uses, the largest first, with the first registered provider of each;
  • every provider of a role in the registry whose package the module contributes, itself or in a variant, and that can be in an app with the module, as <module> with <provider>, such as banner with bloc for a module without a role that contributes flutter_bloc. The case requests the provider, so its roles need no pick. With a provider of a role other than that of the variants of the module, there is a case for each variant that contributes the package, as <module> (<provider of the variant>) with <provider>, or for the first variant if only the module itself contributes it.

A package is a provider's when the provider contributes it itself, not in a variant, with a constraint of its own rather than any, and no module that the provider depends on, directly or not, contributes it so too. Another module takes such a package only in its variant for the provider, or for a provider that depends on it, or when it depends on the provider, and the pipeline checks that only in an app with the provider, which the last cases build. A provider can be in an app with the module when neither they nor the modules they depend on, directly or not, provide a role that takes one provider twice, and each of them that has variants has one for the provider of the role of its variants among them.

A role left out of a subset is still present when a module of the case brings it, such as a provider of several roles or a module that requires it. checkAll then leaves out the case, since the case of a larger subset built its app already and names the roles it has; so it does with a case with a provider whose app another case built.

Implementation

List<ContractCase> casesOfModule(ModuleId id) {
  final module = registry[id];
  if (module == null) throw ArgumentError.value(id, 'id', 'Not registered');
  final descriptor = module.descriptor;
  final used = [
    for (final role in descriptor.effectiveUses)
      if (registry.providersOf(role).isNotEmpty) role,
  ];
  return [
    for (final picks in _picksOf([
      if (descriptor.variants case final variants?) variants.role,
      ...descriptor.effectiveRequires,
    ]))
      for (final subset in _subsets(used))
        _case(
          _caseName(id.value, picks, subset),
          [id],
          picks: picks,
          present: subset,
        ),
    ..._casesWithOwners(module),
  ];
}