flutter_dotenv
Easily configure any flutter application with global variables using a `.env` file.
6.0.1
1000K downloads/mo
#50 most downloaded on pub.dev
java-james/flutter_dotenv
What this package is like to depend on
Last release 4 months ago
21 Apr 2026
Release timing varies
gaps range from 9 days to 1.8 years
Some releases are documented
notes for 9 of 17 stable releases
Nothing withdrawn
no release was ever pulled
8 years old
22 releases · first in 2018
1 release in the last 12 months
see the full history below
Release timeline
22 releases · Dec 2018 to Apr 2026Releases
latest 22-
6.0.121 Apr 2026Release notes
Open source →- [fix]
isEveryDefined()now throwsNotInitializedErrorbeforeload(), consistent with all other read APIs - [fix] Replace
assert()with explicitif/throwingetInt(),getDouble(), andgetBool()so null-safety checks are enforced in release builds - Error messages now include the variable name for easier debugging
- [fix]
load(isOptional: true)no longer discards successfully loaded base file when an override file is missing or empty (fixes #70, #93, #101, #125) - [fix]
clean()now resetsisInitializedtofalse, so accessingenvafterclean()correctly throwsNotInitializedError - [fix] Error classes (
NotInitializedError,FileNotFoundError,EmptyEnvFileError) now include informative messages intoString()instead of the unhelpfulInstance of 'ClassName'(fixes #72, #127; improves diagnostics for #59, #89) FileNotFoundErrorandEmptyEnvFileErrornow carry the filename when available
Note on error message improvements
NotInitializedError,FileNotFoundError, andEmptyEnvFileErrornow overridetoString()with actionable messages (e.g.,FileNotFoundError: Environment file ".env" not found. Ensure the file exists and is listed under assets in pubspec.yaml.). This is not a breaking change — the class names and hierarchy are unchanged, so existingon FileNotFoundErrorcatch clauses continue to work.FileNotFoundErrornow accepts an optional positionalfilenameparameter, andEmptyEnvFileErroraccepts an optional namedfilenameparameter; both default tonullfor backward compatibility.Note on release-build behavior change
In debug mode, behavior is unchanged —
AssertionErrorwas thrown before,AssertionErroris thrown now.In release mode, calling
getInt(),getDouble(), orgetBool()with a missing variable and no fallback previously threw aTypeError(from the null-check operator!) becauseassert()was stripped. It now correctly throwsAssertionErrorwith a descriptive message. If your release-mode code catcheson TypeErroraround these methods, update it to catchon AssertionError(oron Error) instead.Breaking change:
clean()now resets initialization statePreviously, calling
clean()only cleared the env map but leftisInitialized == true. Now it also setsisInitialized = false. Code that callsclean()and then immediately accessesdotenv.envwithout reloading will now throwNotInitializedError. The fix is to callload()orloadFromString()again afterclean(). - [fix]
-
6.0.020 Aug 2025Release notes
Open source →- [feat] Allow passing in override .env files on init
- [feat] Load .env from a passed in string
Breaking changes
-
Renamed:
testLoad→loadFromString
The method has been renamed to better reflect that it can be used outside of test environments.
⚠️ Update your code to callloadFromString()instead oftestLoad(). -
Behavior change: Empty file handling with
isOptional = true
Previously, if the env file was empty andisOptionalwastrue, the method would throw.
Now, in this case, it no longer throws and simply returns an empty env. -
Supported SDK range change: Dropped support for the pre release
2.12.0-0. Now supports2.12.0onwards.
-
6.0.0-rc.320 Aug 2025 pre-releaseNothing published for this version
-
6.0.0-rc.220 Aug 2025 pre-releaseNothing published for this version
-
6.0.0-rc.120 Aug 2025 pre-releaseNothing published for this version
-
5.2.114 Oct 2024 -
5.2.014 Oct 2024Release notes
Open source →- [new] Get variables as
int,doubleandbool - [deps] Upgrade dart sdk constraints to
>=2.12.0-0 <4.0.0 - [new] Export error classes
- [new] Get variables as
-
5.1.001 Jun 2023Release notes
Open source →- [new] Add
isOptionalinit param to prevent throwing if env file is not found - [new] variable name in error message
- [new] Add
-
5.0.212 Aug 2021Nothing published for this version
-
5.0.111 Aug 2021Release notes
Open source →- [fix] Change
testLoad()to be synchronous - [new] Add
get()andmaybeGet()methods for getting values with a fallback
- [fix] Change
-
5.0.028 May 2021Release notes
Open source →- [BREAKING] Wrap dotenv.dart methods within a class
- [fix] Updated documentation to reflect changes and improve clarity
Upgrading from 4.0.x
- Access dotenv methods from the DotEnv class instead of globally.
- Prepend dotenv to all dotenv method calls: e,g,
load()todotenv.load().
4.0.0-nullsafety.1
- [fix] Remove lookbehind regex to support safari browser
-
4.0.0-nullsafety.127 Apr 2021 pre-releaseNothing published for this version
-
4.0.0-nullsafety.004 Mar 2021 pre-releaseRelease notes
Open source →- [BREAKING] Opt into null-safety
- [deps] Upgrade dart sdk constraints to
>=2.12.0-0 <3.0.0 - [new] Allow for escape of $ ' " and \n characters
- [fix] Ensure swallow function only removes leading 'export' keyword
- [fix] Retain spaces within single or double quotes
- [fix] Allow for comments after matching end quotes
- [new] Migrate to null safety
- [new] Create unit test cases for parse
3.1.0
- [new] Allow merging with a custom map on load
3.0.2
- [chore] Format code with dart fmt
3.0.1
- [docs] Use secure links
-
3.1.018 Jan 2021Nothing published for this version
-
3.0.215 Jan 2021Nothing published for this version
-
3.0.114 Jan 2021Nothing published for this version
-
3.0.014 Jan 2021Release notes
Open source →- [new] Merge with Platform.Environment
- [new] Throw precise errors
- [new] Access via functions
- [new] Improved Parsing
- [docs] Example project
2.1.0
- [new] Support '=' sign in value
2.0.3
- [fix] Warning when using with flutter_test
2.0.2
- [fix] Flutter 1.9.5 compatibility ensure binding was initialized
2.0.1
- [docs] tweak app description
- [fix] increase meta version range
-
2.1.027 Nov 2019Nothing published for this version
-
2.0.310 Sep 2019Nothing published for this version
-
2.0.201 Sep 2019Nothing published for this version
-
2.0.112 Dec 2018Nothing published for this version
-
2.0.012 Dec 2018