Search packages, repositories and app categories

Package detailsv4.2.0

dotenv

Load environment variables from a `.env` file.

AndroidiOSmacOSWindowsLinux
30-day downloads
160K
Likes
154
Pub points
135

Install package

flutter pub add dotenv

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The dotenv package enables Flutter applications to load environment variables from a `.env` file, simplifying configuration management across different environments. It reads key-value pairs from the file and makes them accessible within the app, improving security by avoiding hardcoded credentials. This is especially useful for managing API keys, URLs, and other sensitive or environment-specific settings. The package supports all major platforms including Android, iOS, macOS, Windows, and Linux.

Use cases

  • Managing API keys securely
  • Configuring app behavior per environment
  • Storing sensitive credentials
  • Enabling multi-environment setups
  • Avoiding hardcoded configuration values

Key features

  • Loads variables from `.env` file
  • Supports platform-agnostic configuration
  • Simple key-value syntax
  • Easy integration with Flutter apps
  • Secure handling of secrets

Suitable for

  • Development and staging environments
  • Apps requiring multiple configuration profiles
  • Teams managing shared configuration
  • Projects with strict security requirements
  • CI/CD pipelines using environment files

Considerations

  • Never commit `.env` files to version control
  • Ensure `.env` is added to .gitignore
  • Variables are loaded at startup only
  • Limited to simple string values
  • Not suitable for complex data structures

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

dotenv

Load environment variables at runtime from a .env file.

Pub Version Build Status Documentation style: tidy

about

Deploying applications should be simple. This implies constraints:

The twelve-factor app stores config in environment variables (often shortened to env vars or env). Env vars are easy to change between deploys without changing any code... they are a language- and OS-agnostic standard.

An environment is the set of variables known to a process (say, PATH, PORT, ...). It is desirable to mimic the production environment during development (testing, staging, ...) by reading these values from a file.

This library parses that file and optionally merges its values with the built-in Platform.environment map.

usage

See documentation and examples.

cli

Get the latest:

$ dart pub global activate dotenv

Run:

$ dart pub global run dotenv:new  # create a .env file and add it to .gitignore
$ dart pub global run dotenv      # load the file and print only the file environment variables to stdout
$ dart pub global run dotenv -p   # load the file and print all the environment variables to stdout
discussion

Use the issue tracker for bug reports and feature requests.

Pull requests gleefully considered.

prior art
license: MIT

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package