Skip to content
pubscout

envied_generator

1.3.10, released 8 weeks ago by cinibulk.dev

Generates compile‑time Dart constants from .env files for the Envied package.

$ flutter pub add envied_generator
Source repository

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.

Works with

Packages commonly used together with envied_generator: ones it builds on, ones built on it, and its own family.