Skip to content
pubscout

enven

1.3.0, released 8 months ago by tienisto.com

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

WASM-ready
$ flutter pub add enven
Source repository

What it does

Enven reads a .env file during development and generates a Dart file containing typed environment variables at compile time. It supports optional obfuscation, custom types, multiple environment file overrides, and mocking for tests.

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

Use it when

  • You need to embed API keys or secrets securely into your app with optional obfuscation.
  • You want a DRY alternative to envied that only requires a .env file.
  • You need support for multiple environment override files (like .env.prod).

Skip it when

  • You prefer loading environment variables at runtime rather than compile time.
  • You are already using an alternative environment generation tool and don't wish to migrate.

Strengths

  • Generates compile-time environment variables directly from a .env file without verbose configuration.
  • Supports optional obfuscation of sensitive values to prevent easy reverse engineering.
  • Provides built-in support for mocking environment variables during tests.

Weaknesses

  • Subsequent changes may not trigger rebuilds automatically unless build_runner is used in a specific way, and build_runner integration may only work once per change depending on execution.
  • Variables marked with const cannot be overridden via mocking.

Setup

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

Add enven to dev_dependencies, create a .env file in the project root directory, and run `dart run enven`.

import 'package:your_package/gen/env.g.dart';

int apiKey = Env.apiKey;
String apiEndpoint = Env.apiEndpoint;

Alternatives

Packages that do the same job and could replace enven.

  • envied

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

  • pubspec_extract

    Extracts Dart pubspec.yaml file and generates pubspec.dart at build time

  • envied_generator

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

  • protobuf

    Provides runtime support for Dart protocol buffer messages generated by protoc_plugin.

Works with

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