vintage / scratcher

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

Provide a method to reset the revealed percent to default state. #4

Closed laszlo-galosi closed 5 years ago

laszlo-galosi commented 5 years ago

Hi!

Great widget, great work. It would be useful feature, that the widget can reset itself to the default state, so revealed percent is 0, maybe with a defaultState property or something like that, when the points are cleared.

Thanks, Laszlo.

vintage commented 5 years ago

Hey @laszlo-galosi

Thanks for the feature request - it seems like a good improvement to add into library. I'll ping you back at the end of the week, but have already some working prototype locally (so that's definitely possible to implement). Stay tuned :)

Aug-06-2019 21-02-27

My initial idea is to expose some basic API by GlobalKey, so placing Scratcher would look like this:

final key = GlobalKey<ScratcherState>();
Scratcher(key: key, ...);

// ...

RaisedButton(
    child: const Text('Reset'),
    onPressed: () => key.currentState.reset(),
)
vintage commented 5 years ago

@laszlo-galosi The programatic access to scratcher widget just landed in version 1.2.0. It's available on https://pub.dev/packages/scratcher :)