重复使用相同的资产图片时,提高性能的最佳方法是什么?

时间:2019-10-08 13:12:12

标签: flutter dart

我正在尝试减少抖动获取图像的时间,以提高应用程序性能。

我尝试使用带有static const Image/AssetImage xyz = ...的类将Image&AssetImage存储在单个文件中,以方便参考。 一些文章建议使用“继承的小部件”来执行此操作,但它们仅对字符串进行操作。我当前正在使用InheritedWidget:

class CommonImages extends InheritedWidget {
  static CommonImages of(BuildContext context) =>
      context.inheritFromWidgetOfExactType(CommonImages);
  const CommonImages({Widget child, Key key}) : super(key: key, child: child);
  static const Image get profilePic1 => Image(
    fit: BoxFit.contain,
    image: profilePicAsset,
  );
  static const AssetImage profilePicAsset =
      AssetImage

0 个答案:

没有答案