Skip to content

Repository files navigation

DotEnv Plus

A powerful and flexible configuration loader for Dart, supporting nested keys, type conversion, and variable interpolation.

Features

  • Load configuration from .env files, environment variables, and custom sources.
  • Support for nested keys using dot notation (e.g., DATABASE.HOST).
  • Type conversion for common data types (e.g., int, bool, double).
  • Variable interpolation to reference other configuration values (e.g., API_URL=http://${HOST}:${PORT}).
  • Custom mappers to create complex configuration objects from the loaded values.

Usage

import'package:dotenv_plus/dotenv_plus.dart';
voidmain() async {
final config =awaitConfig.load(
sources: [
DotEnv('.env'),
SystemEnv(),
],
extensions: [
return (ConfigBuilder builder) {
builder.map<ConfigMapper>('db', (ctx) {
returnConfigMapper.fromKey(ctx.section);
});
};
]
);
print(config.get<String>('API_URL')); // Output: http://localhost:3000final dbConfig = config.get<DatabaseConfig>('DATABASE');
print(dbConfig.host); // Output: localhost
}

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A powerful and flexible .env file parser for Dart, supporting nested keys, type conversion, and variable interpolation.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages