ConfigSystem constructor

ConfigSystem({
  1. required String configPath,
  2. required String environment,
  3. bool useCache = true,
  4. Duration cacheTtl = const Duration(minutes: 5),
})

Creates a new configuration system.

configPath should point to a directory containing configuration files. environment specifies the environment name for loading environment-specific configs. useCache enables in-memory caching with automatic reloading. cacheTtl sets the time-to-live for cached configurations.

final config = ConfigSystem(
  configPath: 'config',
  environment: 'production',
  useCache: true,
  cacheTtl: Duration(minutes: 10),
);

Throws ConfigException if the configuration directory doesn't exist.

Implementation

ConfigSystem({
  required String configPath,
  required String environment,
  bool useCache = true,
  Duration cacheTtl = const Duration(minutes: 5),
})  : _configPath = configPath,
      _environment = StringBuffer(environment),
      _useCache = useCache,
      _cacheTtl = cacheTtl {
  _loadConfigurations();
}