Skip to content
pubscout

envify

2.0.3, released 4 years ago by frenco.dev

Handle environment variables safely using .env files and code generation.

WASM-ready
$ flutter pub add envify
Source repository

What it does

Envify generates Dart classes containing constant expressions loaded from an environment (.env) file during compile time. This ensures type safety and makes variables available as constant expressions for other annotations.

AI-written summary of version 2.0.3, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want compile-time safety and constant expressions for environment variables.
  • You want to avoid runtime asset loading and decoding overhead for config values.

Skip it when

  • You are starting a new project, as this package has been deprecated in favor of Envied.

Strengths

  • Generates compile-time constant expressions for use in annotations and code generation.
  • Supports multiple environment files via annotations.
  • Casts values to literal types like int, double, num, bool, and String.

Weaknesses

  • The package has been deprecated in favor of Envied and will not receive further updates.

Setup

Kind
Pure Dart
Effort
Low
Code generation
Yes (build_runner)
Direct dependencies
0

Add envify and build_runner to dev_dependencies, create a .env file, and run build_runner.

import 'package:envify/envify.dart';
part 'env.g.dart';

@Envify()
abstract class Env {
    static const key = _Env.key;
}

Alternatives

Packages that do the same job and could replace envify.

  • envied

    Explicitly reads environment variables into a dart file from a .env file.

  • enven

    Generate environment variables from a .env file at compile time with optional obfuscation.

  • envied_generator

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

  • environment_config

    Environment-specific configuration and .env file generator for Flutter and Dart builds.