addBefore method

void addBefore(
  1. String relativeSourceName,
  2. PropertySource newSource
)

Inserts newSource before the named relativeSourceName in the list.

Throws if the referenced source is not found or if the names are equal.

Example:

sources.addBefore('env', MapPropertySource('fallback', {...}));

Implementation

void addBefore(String relativeSourceName, PropertySource newSource) {
  _assertLegalRelativeAddition(relativeSourceName, newSource);
  synchronized(_sources, () {
    _removeIfPresent(newSource);
    int index = _assertPresentAndGetIndex(relativeSourceName);
    _addAtIndex(index, newSource);
  });
}