asset static method

UriAudioSource asset(
  1. String assetPath, {
  2. String? package,
  3. dynamic tag,
})

Convenience method to create an audio source for an asset.

For assets within the same package, this is equivalent to:

AudioSource.uri(Uri.parse('asset:///$assetPath'));

If the asset is to be loaded from a different package, the package parameter must be given to specify the package name.

Implementation

static UriAudioSource asset(String assetPath,
    {String? package, dynamic tag}) {
  final keyName =
      package == null ? assetPath : 'packages/$package/$assetPath';
  return AudioSource.uri(Uri.parse('asset:///$keyName'), tag: tag);
}