getAssetImage static method

Image getAssetImage(
  1. String assetFilePath, {
  2. BoxFit? fit,
  3. bool gaplessPlayback = false,
  4. String? package,
})

assetFilePath assets 资源文件路径 package 访问某个 package 里的资源,这里默认为 'bruno' scale 与所用的 png 资源是 icon_2x.png (scale=2.0),icon_3x.png(scale=3.0)

Implementation

static Image getAssetImage(String assetFilePath,
    {BoxFit? fit, bool gaplessPlayback = false, String? package}) {
  if (!assetFilePath.startsWith('assets')) {
    assetFilePath = 'assets/$assetFilePath';
  }
  return Image.asset(
    assetFilePath,
    package: package ?? BaseStrings.flutterPackageName,
    fit: fit,
    scale: 3.0,
    gaplessPlayback: gaplessPlayback,
  );
}