at static method

DVAssetSource at(
  1. String root
)

The source for root: what was registered for it or for a directory it is under, or the directory itself.

Implementation

static DVAssetSource at(String root) {
  final DVAssetSource? exact = _registered[root];
  if (exact != null) return exact;
  for (final MapEntry<String, DVAssetSource> entry in _registered.entries) {
    for (final String separator in <String>{'/', Platform.pathSeparator}) {
      if (root.startsWith('${entry.key}$separator') && entry.value is DVPackedAssets) {
        final DVPackedAssets packed = entry.value as DVPackedAssets;
        final String under = root.substring(entry.key.length + 1).replaceAll(separator, '/');
        return DVPackedAssets(packed.pack, prefix: '${packed.prefix}$under/');
      }
    }
  }
  return DVDirectoryAssets(root);
}