getDotEnv method

Map<String, String> getDotEnv()

Get the content of the .env file as a Map<String, String> object.

Implementation

Map<String, String> getDotEnv() {
  if (!File(filePath).existsSync()) {
    return {};
  } else {
    for (var eachLine in File(filePath).readAsLinesSync()) {
      try {
        _env[eachLine.split('=')[0]] = eachLine.replaceFirst(eachLine.split('=')[0] + '=', '');
      } catch (error) {
        _env[eachLine.split('=')[0]] = '';
      }
    }
    return _env;
  }
}