envied_generator
1.3.10, released 8 weeks ago by cinibulk.dev
Generates compile‑time Dart constants from .env files for the Envied package.
What it does
The generator reads .env files at build time and creates a Dart class exposing the variables as typed constants. It also supports obfuscation, hidden files, and inheritance of .env files.
AI-written summary of version 1.3.10, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need compile‑time access to environment variables
- You want obfuscation of secret values in the compiled app
- You prefer type‑safe constants over runtime string lookups
Skip it when
- You need to change env values without rebuilding
- You prefer a pure runtime solution like dotenv
- You cannot add a build step to your CI
Strengths
- Compile‑time safety and no runtime parsing
- Built‑in obfuscation of secrets
- Supports hidden files and .env inheritance
Weaknesses
- Requires build_runner and a code‑gen step
- Cannot handle dynamic env changes at runtime
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- Yes (build_runner)
- Direct dependencies
- 8
Add envied and envied_generator to dev_dependencies, run `flutter pub run build_runner build` after adding annotations.
import 'package:envied/envied.dart';
part 'my_env.g.dart';
@Envied(path: '.env')
abstract class MyEnv {
@EnviedField(varName: 'API_KEY')
static const apiKey = _MyEnv.apiKey;
}
Alternatives
Packages that do the same job and could replace envied_generator.
- openapi_generator_annotations
Annotation package for configuring openapi_generator client SDKs.
66Compare - retrofit_generator
Generates Dio client code from Retrofit‑style annotations.
89Compare - drift_dev
Generates Dart database code from Drift table definitions as a dev‑dependency.
84Compare - chopper_generator
Generates type‑safe Chopper client code from annotated service interfaces.
78Compare
Works with
Packages commonly used together with envied_generator: ones it builds on, ones built on it, and its own family.
- analyzerenvied_generator depends on itPerforms static analysis of Dart code for tool integration and embedding.
- package_configenvied_generator depends on itRead and write Dart package configuration files.
- code_builderenvied_generator depends on itA fluent, builder-based library for generating valid Dart code programmatically.
- buildenvied_generator depends on itPackage for authoring build_runner compatible code generators.
- equatableenvied_generator depends on itProvides value‑based equality for Dart objects without manual == and hashCode.
- source_genenvied_generator depends on itSource code generation builders and utilities for the Dart build system.
- recaseenvied_generator depends on itChanges the case of input text to various conventions.
- enviedenvied_generator depends on itExplicitly reads environment variables into a dart file from a .env file.