bySourceRef method

CanvasAssetLibraryItem? bySourceRef(
  1. String ref
)

Finds an asset by its source or thumbnail reference.

References with an asset: prefix are matched against the equivalent unprefixed reference.

Implementation

CanvasAssetLibraryItem? bySourceRef(String ref) {
  final normalized = _normalizeRef(ref);

  for (final item in items) {
    if (_normalizeRef(item.sourceRef) == normalized) {
      return item;
    }

    if (_normalizeRef(item.thumbnailRef) == normalized) {
      return item;
    }
  }

  return null;
}