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, Image.asset() still show black scratcher #11

Closed arnab-ios closed 4 years ago

arnab-ios commented 4 years ago

I am using scratcher for making scratch card in flutter. I used one image as scratch card image, it was working perfectly for first few days. Then we wanted to change the image, so I replaced the image with a new one. After that the black issue started occurring.

Operating system:

What I tried:

My observations:

Code:

Container(
      margin: const EdgeInsets.fromLTRB(80.0, 80.0, 80.0, 10.0),
      child: AspectRatio(
        aspectRatio: 1,
        child: Scratcher(
          key: scratchKey,
          brushSize: 50,
          threshold: 60,
          image: Image.asset('assets/images/scratch_card.png'),    // <-- this image is not loading
          onChange: (value) {
            print("Scratch progress: $value%");
          },
          onThreshold: () {
            print("Threshold reached, you won!");           
          },
          child: Container(
            decoration: BoxDecoration(
                borderRadius: BorderRadius.all(
                  const Radius.circular(18.0),
                ),
                border: Border.all(
                    color: Colors.blue, width: 2.0),
                color: Colors.white),
            child: Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Container(
                    height: 70.0,
                    width: 100.0,
                    margin: const EdgeInsets.only(top: 10.0, bottom: 20.0),
                    child: Image.asset('assets/images/logo_light.png'),
                  ),
                  Container(
                    margin: const EdgeInsets.all(10.0),
                    child: Text(
                      100,
                      style: TextStyle(
                        color: Colors.blue,
                        fontSize: 26.0,
                        fontFamily: 'rubik_medium',
                      ),
                    ),
                  )
                ],
              ),
            ),
          ),
        ),
      ),
    );

Dependencies:

dependencies:
  scratcher: ^1.3.0

Flutter version:

Flutter 1.20.0-3.0.pre.80 • channel master •

When I run the project on debug mode the, i got debugger error on my-local-path/flutter/.pub-cache/hosted/pub.dartlang.org/scratcher-1.3.0/lib/widgets.dart file inside Future<ui.Image> _loadImage(Image image) function on line where it is written imageProvider.load(key. No log on console.

I have checked this issue and i've upgraded my flutter version, though i was in higher version already. Please let me know any solution. Thank you.

arnab-ios commented 4 years ago

Okay so I basically went to channel beta from master in flutter and that solved the issue. So it seems issue with flutter, not with the library. But if anyone in the future find any other solutions, please do let me know. Thank you.

Previous version: Flutter 1.20.0-3.0.pre.80 • channel master Current version: Flutter 1.19.0-4.2.pre • channel beta

vintage commented 4 years ago

The plug-in itself is only tested against the stable release of Flutter, but glad it's working with the beta as well 😎