loadFromString method
void
loadFromString({})
Implementation
void loadFromString({
// The env string to load
String envString = '',
// A optional list of other env strings whose values will override values read from [envString]
List<String> overrideWith = const [],
// A map of key-value pairs to merge with the loaded env variables
Map<String, String> mergeWith = const {},
// Whether to ignore not found and empty file errors when loading the env string
bool isOptional = false,
// An optional custom parser to use for parsing the env string
Parser parser = const Parser(),
}) {
clean();
if (envString.isEmpty && !isOptional) {
throw EmptyEnvFileError();
}
final linesFromFile = envString.split('\n');
final linesFromOverrides = overrideWith.expand((s) => s.split('\n')).toList();
_mergeAndStore(
linesFromFile: linesFromFile,
linesFromOverrides: linesFromOverrides,
mergeWith: mergeWith,
parser: parser,
);
}