loadEnvironment method
void
loadEnvironment()
Implementation
void loadEnvironment() {
final dir = Directory.current;
final elements = dir.listSync();
final environments = elements
.where((element) =>
element is File && element.uri.pathSegments.last.contains('.env'))
.toList();
final orderedFiles = orderEnvFiles(environments);
if (orderedFiles.isNotEmpty) {
final environment = orderedFiles.first;
final lines = File.fromUri(environment.uri).readAsLinesSync();
for (final line
in lines.nonNulls.where((element) => element.isNotEmpty)) {
final [key, value] = switch (line.contains('=')) {
true => line.split('='),
false => line.split(':'),
};
_values[key] = value;
}
}
_values.addEntries(Platform.environment.entries);
}