resolveKey method
Resolves sourcePath (relative to the owning package's root, with or
without the .glb/.fsceneb extension) to exactly one scene asset key.
Implementation
String resolveKey(String sourcePath, {String? package}) {
final id = _sceneId(sourcePath);
final matches = _entries
.where(
(entry) =>
entry.sceneId == id &&
(package == null || entry.package == package),
)
.toList();
if (matches.isEmpty) {
throw StateError(
'No DataAssets-backed .fsceneb for source "$sourcePath" was found. '
'Make sure the build hook calls buildScenes in a DataAssets mode, that '
'Dart data assets are enabled (flutter config '
'--enable-dart-data-assets), and that the app has been rebuilt.',
);
}
if (matches.length > 1) {
final choices = matches.map((match) => match.package).join(', ');
throw StateError(
'Multiple DataAssets-backed .fsceneb files for source "$sourcePath" '
'were found in packages: $choices. Pass package to disambiguate.',
);
}
return matches.single.assetKey;
}