baseDirectory property

String baseDirectory

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


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.


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

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

  // 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 {
  } while (0 < length && Platform.pathSeparator == normalizedValue[length]);
  assert(0 < length);

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