{"id":13465541,"url":"https://github.com/vintage/scratcher","last_synced_at":"2025-04-12T14:57:09.504Z","repository":{"id":39963363,"uuid":"198284067","full_name":"vintage/scratcher","owner":"vintage","description":"Scratch card widget which temporarily hides content from user.","archived":false,"fork":false,"pushed_at":"2023-11-24T13:38:55.000Z","size":5009,"stargazers_count":618,"open_issues_count":10,"forks_count":70,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-03T14:11:22.309Z","etag":null,"topics":["flutter","flutter-plugin","flutter-widget"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/scratcher","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vintage.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-07-22T18:51:35.000Z","updated_at":"2025-04-02T03:06:33.000Z","dependencies_parsed_at":"2023-11-24T14:46:05.662Z","dependency_job_id":null,"html_url":"https://github.com/vintage/scratcher","commit_stats":{"total_commits":49,"total_committers":9,"mean_commits":5.444444444444445,"dds":0.6326530612244898,"last_synced_commit":"78e482fb734c9eedad7cf542994c1b745c15ebeb"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vintage%2Fscratcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vintage%2Fscratcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vintage%2Fscratcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vintage%2Fscratcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vintage","download_url":"https://codeload.github.com/vintage/scratcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586249,"owners_count":21128997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flutter","flutter-plugin","flutter-widget"],"created_at":"2024-07-31T15:00:31.722Z","updated_at":"2025-04-12T14:57:09.481Z","avatar_url":"https://github.com/vintage.png","language":"Dart","funding_links":[],"categories":["Components","组件","Dart","UI [🔝](#readme)","Packages"],"sub_categories":["UI"],"readme":"# scratcher\n\nScratch card widget which temporarily hides content from the user.\n\n[![Version](https://img.shields.io/badge/pub-v2.5.0-blue.svg)](https://pub.dartlang.org/packages/scratcher)\n\n![Demo](https://media.giphy.com/media/fXztsRTXoKsVuChtTl/giphy.gif)\n\n## Features\n\n- Supported platforms:\n  - Android\n  - iOS\n  - Web (CanvasKit only)\n- Cover content with full color or custom image \n- Track the scratch progress and threshold\n- Fully configurable\n\n## Getting started\n\n1. First thing you need to do is adding the scratcher as a project dependency in `pubspec.yaml`:\n```yaml\ndependencies:\n scratcher: \"^2.5.0\"\n```\n\n2. Now you can install it by running `flutter pub get` or through code editor.\n\n## Setting up\n\n1. Import the library:\n```dart\nimport 'package:scratcher/scratcher.dart';\n```\n\n2. Cover desired widget with the scratch card:\n\n```dart\nScratcher(\n  brushSize: 30,\n  threshold: 50,\n  color: Colors.red,\n  onChange: (value) =\u003e print(\"Scratch progress: $value%\"),\n  onThreshold: () =\u003e print(\"Threshold reached, you won!\"),\n  child: Container(\n    height: 300,\n    width: 300,\n    color: Colors.blue,\n  ),\n)\n```\n\n## Properties\n\nProperty | Type | Description\n--- | --- | ---\nchild | Widget | Widget rendered under the scratch area.\nenabled | bool | Whether new scratches can be applied.\nthreshold | double | Percentage level of scratch area which should be revealed to complete.\nbrushSize | double | Size of the brush. The bigger it is the faster user can scratch the card.\naccuracy | ScratchAccuracy | Determines how accurate the progress should be reported. Lower accuracy means higher performance.\ncolor | Color | Color used to cover the child widget.\nimage | Image | Image widget used to cover the child widget.\nrebuildOnResize | bool | Determines if the scratcher should rebuild itself when space constraints change (resize).\nonChange | Function | Callback called when new part of area is revealed (min 0.1% difference).\nonThreshold | Function | Callback called when threshold is reached (only when defined).\nonScratchStart | Function | Callback called when scratching starts.\nonScratchUpdate | Function | Callback called during scratching.\nonScratchEnd | Function | Callback called when scratching ends.\n\n## Programmatic access\n\nYou can control the Scratcher programmatically by assigning the `GlobalKey` to the widget.\n\n```dart\nfinal scratchKey = GlobalKey\u003cScratcherState\u003e();\n\nScratcher(\n  key: scratchKey,\n  // remaining properties\n)\n```\n\nAfter assigning the key, you can call any exposed methods e.g.:\n\n```dart\nRaisedButton(\n  child: const Text('Reset'),\n  onPressed: () {\n    scratchKey.currentState.reset(duration: Duration(milliseconds: 2000));\n  },\n);\n```\n\nMethod | Description\n--- | ---\nreset | Resets the scratcher state to the initial values.\nreveal | Reveals the whole scratcher, so than only original child is displayed.\n\n## Example Project\n\nThere is a crazy example project in the `example` folder. Check it out to see most of the available options.\n\n## Resources\n\n- [https://www.youtube.com/watch?v=EM4D1pUpadA](https://www.youtube.com/watch?v=EM4D1pUpadA) by The CS Guy\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvintage%2Fscratcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvintage%2Fscratcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvintage%2Fscratcher/lists"}