vintage / scratcher

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

Wrong size when using CachedNetworkImage #32

Closed rubenaster closed 3 years ago

rubenaster commented 3 years ago

Hey,

I'm using Scratcher with CachedNetworkImage and the issue I have is that on the first call of OnDraw after the image is loaded I get a size of (10, 10). Quickly afterwards OnDraw is called again with the correct size.

The problem is that the first call of OnDraw already initializes the points lists.

Now my current workaround is to check in OnDraw if the size has changed and if so I re-initialize the points. Of course this might lead to issues.

It works for now since the OnDraw calls appear quickly one ofter the other but maybe you have a better idea?

vintage commented 3 years ago

Potential solution to this would be recalculating the scratcher progress when the size of canvas changes. Probably somewhere here https://github.com/vintage/scratcher/blob/master/lib/widgets.dart#L140 a test against constraints could be added to solve the problem.

Well, it would also solve the https://github.com/vintage/scratcher/issues/30 as that's the same thing.

vintage commented 3 years ago

Fixed in 2.1.0 https://pub.dev/packages/scratcher