envied
1.3.10, released 8 weeks ago by cinibulk.dev
Explicitly reads environment variables into a dart file from a .env file.
What it does
Reads environment variables from a .env file or system environment variables at build time and generates a part file with typed constants. It supports obfuscation, optional fields, inheritance, and multiple environments.
AI-written summary of version 1.3.10, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want compile-time safety and type checking for your environment variables.
- You need to obfuscate sensitive keys or support multiple environments via .env files.
Skip it when
- You need to read or change environment variables dynamically at runtime.
- You cannot use code generation or build_runner in your workflow.
Strengths
- Type-safe access to environment variables
- Supports obfuscation and encryption options
- Flexible configuration via build.yaml, annotations, and CLI overrides
Weaknesses
- Requires build_runner and code generation steps
- Changes to hidden env files may not automatically trigger incremental rebuilds without build.yaml configuration
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 0
Add envied and dev:envied_generator and dev:build_runner, then run build_runner build.
import 'package:envied/envied.dart';
part 'env.g.dart';
@envied
abstract class Env {
@EnviedField(varName: 'KEY')
static const String key = _Env.key;
}Alternatives
Packages that do the same job and could replace envied.
- enven
Generate environment variables from a .env file at compile time with optional obfuscation.
59Compare - envify
Handle environment variables safely using .env files and code generation.
48Compare - pubspec_extract
Extracts Dart pubspec.yaml file and generates pubspec.dart at build time
75Compare - flutter_secure_dotenv_generator
A development dependency to generate secure dotenv file for flutter_secure_dotenv package.
50Compare
Works with
Packages commonly used together with envied: ones it builds on, ones built on it, and its own family.