readTcProperties function

Map<String, String> readTcProperties()

Reads ~/.testcontainers.properties and returns its key-value pairs.

The file format mirrors the Java .properties convention: each non-blank line that contains an = character is split on the first = and both the key and value are stripped of leading/trailing whitespace. Lines that do not contain = are ignored. Quoted values are not supported.

Returns an empty map when the file does not exist.

Implementation

Map<String, String> readTcProperties() {
  final home = Platform.environment['HOME'] ?? '';
  final file = File('$home/.testcontainers.properties');
  if (!file.existsSync()) {
    return {};
  }
  final settings = <String, String>{};
  for (final line in file.readAsLinesSync()) {
    final idx = line.indexOf('=');
    if (idx < 0) {
      continue;
    }
    final key = line.substring(0, idx).trim();
    final value = line.substring(idx + 1).trim();
    settings[key] = value;
  }
  return settings;
}