baseDirectory property

String baseDirectory

Returns the base directory where JSON files are loaded from, defaults to 'res/l10n'.

Implementation

static String get baseDirectory => _baseDirectory;
void baseDirectory=(String path)

Sets a new base directory where JSON files are loaded from.

This will cause the internal cache to be cleared when value is indeed different than the current one.

Implementation

static set baseDirectory(String path) {
  assert(null != path);
  assert(Directory(path).existsSync());

  var normalizedValue = (path ?? '').trim();
  assert(normalizedValue.isNotEmpty);

  // Must not be an absolute path, at least on Linux/macOS.
  assert(Platform.pathSeparator != normalizedValue[0]);

  // Trim trailing path separator from end of string.
  var length = normalizedValue.length;
  do {
    length--;
  } while (0 < length && Platform.pathSeparator == normalizedValue[length]);
  assert(0 < length);

  normalizedValue = normalizedValue.substring(0, length);
  if (normalizedValue != _baseDirectory) {
    _cache.clear();
    _baseDirectory = normalizedValue.substring(0, length);
  }
}