EnvParser class

Parses the raw text content of a .env file into a flat key-value map.

Parsing rules:

  • Blank lines are ignored.
  • Lines starting with # are treated as comments and ignored.
  • Keys and values are trimmed of surrounding whitespace.
  • The first = in a line is the delimiter; subsequent = characters are part of the value (e.g. KEY=a=b{'KEY': 'a=b'}).
  • Lines without = are ignored.
  • Values wrapped in matching single or double quotes have the quotes stripped. Content inside quotes is taken verbatim (inline comments are not stripped from quoted values).
  • For unquoted values, anything after # is treated as an inline comment and discarded.
  • Both LF and CRLF line endings are handled.

Constructors

EnvParser()

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse(String raw) Map<String, String>
Parses raw .env content and returns a Map<String, String>.
toString() String
A string representation of this object.
inherited

Operators

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