getAssetUri static method

Uri getAssetUri(
  1. String assetName
)

Returns a URI for a Flutter asset.

  • In debug mode, resolves to a file URI to the asset itself
  • In non-MSIX release builds, resolves to a file URI to the bundled asset
  • In MSIX releases, resolves to an ms-appx URI from Msix.getAssetUri.

Implementation

static Uri getAssetUri(String assetName) {
  if (kDebugMode) {
    return Uri.file(File(assetName).absolute.path, windows: true);
  } else if (MsixUtils.hasPackageIdentity()) {
    return MsixUtils.getAssetUri(assetName);
  } else {
    return Uri.file(
      File('data/flutter_assets/$assetName').absolute.path,
      windows: true,
    );
  }
}