vintage / scratcher

Scratch card widget which temporarily hides content from user.
https://pub.dev/packages/scratcher
MIT License
572 stars 67 forks source link

Image doesn't show after upgrading to flutter 3.16.0 #53

Closed h1amza closed 9 months ago

h1amza commented 9 months ago

My code: Capture0

Console output: Capture

h1amza commented 9 months ago

@vintage @xrusu @wenxiangjiang @andersonmendess can u help plz?

h1amza commented 9 months ago

The Problem is in _loadImage logic (widget.dart) because imageProvider.load is now imageProvider.loadImage

h1amza commented 9 months ago

i fix that :

// Asynchronously loads an image and returns a Future of ui.Image.
  Future<ui.Image> _loadImageAsync(Image imageWidget) async {
    // Create a completer to manage the asynchronous operation.
    final Completer<ui.Image> imageCompleter = Completer<ui.Image>();

    // Obtain the image provider from the Image widget.
    final ImageProvider imageProvider = imageWidget.image;

    // Obtain a key for the image.
    final imageKey = await imageProvider.obtainKey(ImageConfiguration.empty);

    // Load the image using the obtained key.
    imageProvider.loadImage(
      imageKey,
      (ui.ImmutableBuffer buffer, {ui.TargetImageSizeCallback? getTargetSize}) {
        return ui.instantiateImageCodecFromBuffer(buffer);
      },
    ).addListener(ImageStreamListener((ImageInfo image, _) {
      imageCompleter.complete(image.image);
    }));

    // Return the future from the completer.
    return imageCompleter.future;
  }
chipmunkk-studio commented 9 months ago

is that fixed?

vintage commented 9 months ago

Fixed in 2.5.0