scratch_to_win 0.2.5 copy "scratch_to_win: ^0.2.5" to clipboard
scratch_to_win: ^0.2.5 copied to clipboard

Scratchable overlay to reveal hidden widgets with gestures and callbacks. Supports progress tracking, confetti, haptics, sound, brush textures, image overlays, and a controller for reset/reveal-all.

scratch_to_win #

CI Pages pub package style: flutter lints

CI / Pages badges reflect the latest GitHub Actions run; if they look wrong on pub.dev, wait a few minutes and hard-refresh — image caches can lag.

Flutter widget: a scratch-off layer on top of any child. Drag to reveal what is underneath. Pointer lifecycle callbacks and an optional grid-based estimate of cleared area (for thresholds and win logic).

Install #

dependencies:
  scratch_to_win: ^0.2.4

Try the interactive example #

  • Live (web): GitHub Pages demo — enable Settings → Pages → GitHub Actions in this repo on first use; the Deploy example (web) workflow must succeed once.
  • In the package: the published tarball includes the example/ Flutter project (interactive “lab” for every API option).
  • On pub.dev, open the package’s repository link to browse example/ online, or use your pub cache after dart pub get.

Quick start #

ScratchToWin(
  child: Center(child: Text('You won!')),
  onRevealProgress: (f) => debugPrint('cleared: $f'),
  onThresholdReached: (f) => debugPrint('threshold at $f'),
)

API overview #

Area Details
Callbacks onScratchStart, onScratchUpdate, onScratchEnd, onScratchCancel, onRevealProgress, onThresholdReached
Brush Round stroke: brushRadius; optional brushTexture (ImageProvider)
Progress trackRevealProgress, progressGridResolution (see class docs), revealThreshold
Control ScratchToWinController.reset(), revealAll(), enabled
Surface overlayColor, overlayGradient, overlayImage, overlayImageFit, borderRadius
Completion playConfettiOnThreshold, confettiParticleCount, confettiDuration, confettiMinChipSize, confettiMaxChipSize; optional sound
Accessibility showRevealAssistButton, revealAssistButtonLabel ('' hides if switch on), revealAssistPadding

Pure Flutter drawing for the scratch layer; built-in full-card confetti (no extra package). Optional audioplayers for completion SFX. Optional haptics on start and when the threshold is crossed.

Example (local) #

git clone https://github.com/Dev-Muhammad-Junaid/scratch_to_win.git
cd scratch_to_win/example
flutter pub get
flutter run

See example/README.md for the lab app, web build, and pub.dev layout.

Development #

flutter pub get
flutter analyze
flutter test

Publish checks: dart pub publish --dry-run. See pub.dev scoring for documentation and analysis expectations.

License #

MIT. See LICENSE.

2
likes
140
points
240
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Scratchable overlay to reveal hidden widgets with gestures and callbacks. Supports progress tracking, confetti, haptics, sound, brush textures, image overlays, and a controller for reset/reveal-all.

Repository (GitHub)
View/report issues

Topics

#ui #animation #widget #game

License

MIT (license)

Dependencies

audioplayers, flutter

More

Packages that depend on scratch_to_win