replace method

void replace(
  1. String name,
  2. PropertySource propertySource
)

Replaces the property source with the given name with propertySource.

The names must match, and the target must already exist.

Throws:

  • IllegalArgumentException if no source with the given name exists.

Example:

sources.replace('env', MapPropertySource('env', {'mode': 'prod'}));

Implementation

void replace(String name, PropertySource propertySource) {
  return synchronized(_sources, () {
    int index = _assertPresentAndGetIndex(name);
    _sources[index] = propertySource;
  });
}