reorder method

void reorder(
  1. List<PropertySourceOrderRule> rules
)

Reorders property sources using the provided rules.

Each rule is applied in the order given. Later rules may refine or override earlier ones. The reordering is executed atomically.

Example:

sources.reorder([
  BeforeRule('env', 'defaults'),
  PriorityRule({'system': 0, 'env': 1, 'defaults': 99}),
]);

Implementation

void reorder(List<PropertySourceOrderRule> rules) {
  synchronized(_sources, () {
    List<PropertySource> working = List.of(_sources);
    for (final rule in rules) {
      working = rule.apply(working);
    }

    _sources = working;
  });
}