penv
.env loader for Dart

Exceptions

Part of the API Reference.

EnvFileNotFoundException

Thrown by penvload/penvloadAsync when the requested .env file does not exist.

class EnvFileNotFoundException implements Exception {
  final String path;
  final bool createFile;
}
Field Meaning
path The path that was looked up and could not be found.
createFile Whether a placeholder file was created at path before this exception was thrown. true: a template file was written — fill it in and run again. false: no file was written — create path yourself first.

Depending on how penvload was called, a placeholder template file may have already been written to path before this exception was thrown — check createFile to see which case applies.

MissingRequiredKeysException

Thrown by penvload, penvloadOrNull, and penvloadAsync when one or more required keys are missing from the parsed environment, or are present with a blank (empty-string) value.

class MissingRequiredKeysException implements Exception {
  final List<String> keys;
}

keys lists every requested-but-missing (or blank) key after parsing — check all of them at once instead of failing on the first.