EnvReader class

Reads and converts env values for a @DoxEnv() class.

A real environment variable wins over the .env file, the same as Env.get(). An empty value (or the text null) counts as missing.

Each read gives null when the key is missing or not valid. A bad value is saved and check throws one EnvException with every problem.

Constructors

EnvReader({Map<String, String>? environment, Map<String, String>? dotEnv})
environment is Platform.environment and dotEnv is the .env file by default. Tests can pass their own maps.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

boolean(String key) → bool?
true, 1, yes, on / false, 0, no, off (any case)
check() → void
throws an EnvException with every missing or bad key
decimal(String key) → double?
duration(String key) → Duration?
a number with a unit: 500ms, 30s, 5m, 2h, 1d. A plain number is seconds: 300 is 5 minutes.
enumByName<T extends Enum>(String key, List<T> values) → T?
an enum value by its name, in any case
integer(String key) → int?
list(String key) → List<String>?
comma separated: a, b,c is ['a', 'b', 'c']. Empty items are dropped.
need(String key) → void
saves an error when the required key is missing
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
number(String key) → num?
raw(String key) → String?
the raw text of key, or null when it is missing or empty
string(String key) → String?
toString() → String
A string representation of this object.
inherited
uri(String key) → Uri?

Operators

operator ==(Object other) → bool
The equality operator.
inherited