ConfigDataEnvironment constructor

ConfigDataEnvironment(
  1. ConfigurableEnvironment environment, {
  2. ResourceLoader? resourceLoader,
  3. List<PropertySourceLoader> loaders = const [PropertiesPropertySourceLoader(), YamlPropertySourceLoader()],
  4. List<String> defaultLocations = defaultSearchLocations,
  5. List<String> additionalProfiles = const [],
})

Creates a loader that will fill environment; nothing is read until processAndApply or processAndApplySync.

resourceLoader finds the files (a DefaultResourceLoader unless given; pass one with a ProtocolResolver for Flutter assets or files held in memory). loaders read the file formats, picked by extension. defaultLocations replaces defaultSearchLocations, each entry a group of ;-separated locations; spring.config.location still overrides it. additionalProfiles are activated on top of the configured ones.

// Config files held in memory, for a test.
ConfigDataEnvironment(
  environment,
  resourceLoader: DefaultResourceLoader(
    protocolResolvers: [InMemoryProtocolResolver('memory:', files)],
  ),
  loaders: const [
    PropertiesPropertySourceLoader(),
    YamlPropertySourceLoader(),
  ],
  defaultLocations: const ['optional:memory:;optional:memory:config/'],
);

Implementation

ConfigDataEnvironment(
  this.environment, {
  ResourceLoader? resourceLoader,
  List<PropertySourceLoader> loaders = const [
    PropertiesPropertySourceLoader(),
    YamlPropertySourceLoader(),
  ],
  List<String> defaultLocations = defaultSearchLocations,
  List<String> additionalProfiles = const [],
}) : resourceLoader = resourceLoader ?? DefaultResourceLoader(),
     loaders = List.unmodifiable(loaders),
     defaultLocations = List.unmodifiable(defaultLocations),
     additionalProfiles = List.unmodifiable(additionalProfiles);