Upgrading dotenv 3 to 4
Breaking3.0.0 → 4.2.0Breaking4New4Fixed1
BreakingUpgrade verdict
4 breaking changes.
In plain terms
- The old standalone helper functions are gone. You now create a DotEnv object and call methods on it.
- Environment variables from the operating system are no longer merged in by default. Libraries should pass includePlatformEnvironment: true, and the dotenv command should use the --merge-platform-vars flag.
- You can no longer read the raw key-value map directly. Use the DotEnv methods that pass values through instead.
- If a key appears more than once, the later value now wins instead of the first one being kept.
Must act Top 3 of 4 that need code or config changes
Dart SDK requirement changed in 4.2.0: >=2.12.0 <3.0.0 → >=2.16.0 <4.0.0.
Moves args ^2.1.0 → ^2.3.0, meta ^1.3.0 → ^1.7.0. Your build may pick other versions.
What you must change
Breaking4
Removes top-level functions; callers must use a DotEnv() instance instead.
DotEnv()By default the underlying map no longer includes Platform.environment; opt in via includePlatformEnvironment or --merge-platform-vars.
Platform.environmentDotEnv(includePlatformEnvironment: true)--merge-platform-varsStops exposing the underlying Map<String, String>; use the forwarding methods on DotEnv instead.
Map<String, String>DotEnvDuplicate keys are now overwritten instead of ignored.
API changes
Generated by DepDelta from published Dart source. Not mixed with prose notes.
- removed:
class Parser - removed:
ctor Parser() - removed:
function clean(): Map - removed:
function isEveryDefined(Iterable<String> vars): bool - removed:
function load([String filename = …, Parser psr = …]): void - removed:
get env: Map<String, String> - removed:
method Parser.interpolate(String val, Map<String, String> env): String - removed:
method Parser.parse(Iterable<String> lines): Map<String, String> - removed:
method Parser.parseOne(String line, {Map<String, String> env = …}): Map<String, String> - removed:
method Parser.strip(String line): String - removed:
method Parser.surroundingQuote(String val): String - removed:
method Parser.swallow(String line): String - removed:
method Parser.unquote(String val): String - removed:
variable String>.from(Platform.environment): var - added:
class DotEnv - added:
ctor DotEnv({this.includePlatformEnvironment = …, this.quiet = …}) - added:
field DotEnv.String>: final - added:
field DotEnv.includePlatformEnvironment: final bool - added:
field DotEnv.quiet: final bool - added:
get DotEnv.map: Map<String, String> - added:
method DotEnv.addAll(Map<String, String> other): void - added:
method DotEnv.clear(): void - added:
method DotEnv.getOrElse(String key, String Function() orElse): String - added:
method DotEnv.isDefined(String key): bool - added:
method DotEnv.isEveryDefined(Iterable<String> vars): bool - added:
method DotEnv.load( [Iterable<String> filenames = …, Parser psr = …]): void - added:
method DotEnv.operator [](String key): String?