Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration from the AssetBundlePictureKey apis #1070

Open
dovahkiin98 opened this issue May 28, 2024 · 0 comments
Open

Migration from the AssetBundlePictureKey apis #1070

dovahkiin98 opened this issue May 28, 2024 · 0 comments

Comments

@dovahkiin98
Copy link

I have code using classes like AssetBundlePictureKey, ExactAssetPicture, etc. But I can't seem to find any migration guide for that code?

Can someone help me?

class DynamicAssetPicture extends ExactAssetPicture {
  final int cacheHash;

  DynamicAssetPicture(
    super.assetName,
    super.decoderBuilder,
    this.cacheHash,
  );

  @override
  Future<OverrideSvgKey> obtainKey(PictureConfiguration picture) {
    return SynchronousFuture<OverrideSvgKey>(
      OverrideSvgKey(
        bundle: bundle ?? picture.bundle ?? rootBundle,
        name: keyName,
        colorFilter: colorFilter,
        cacheHash: cacheHash,
      ),
    );
  }

  @override
  bool operator ==(Object other) {
    if (other is DynamicAssetPicture) {
      return cacheHash == other.cacheHash;
    }

    return false;
  }

  @override
  int get hashCode => Object.hash(super.hashCode, cacheHash);
}

class OverrideSvgKey extends AssetBundlePictureKey {
  final int cacheHash;

  const OverrideSvgKey({
    required super.bundle,
    required super.name,
    super.colorFilter,
    required this.cacheHash,
  }) : super(
          theme: const SvgTheme(),
        );

  @override
  bool operator ==(dynamic other) => hashCode == other.hashCode;

  @override
  int get hashCode => Object.hash(super.hashCode, cacheHash);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant