パッケージ、リポジトリ、アプリカテゴリを検索

scratcher のカバー
パッケージ詳細v2.5.0

scratcher

ユーザーのコンテンツを一時的に非表示にするスクラッチカードウィジェット。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1.5万
いいね数
501
Pub ポイント
140

パッケージをインストール

flutter pub add scratcher

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

スクラッチャー パッケージは、ユーザーが「こすり」始めるまでコンテンツを一時的に隠す、スクラッチカード体験をシミュレートする Flutter ウィジェットを提供します。ゲーム化インターフェース、報酬システム、アプリ内のサプライズな開示に最適です。モバイル、ウェブ、デスクトップを含むすべての主要プラットフォームでタッチ操作をサポートしています。カスタマイズ可能なスクラッチ効果と視覚フィードバックにより、ユーザー参加度が向上します。パフォーマンスとインテグレーションの容易さを重視して設計されており、複雑な実装なしにインタラクティブ要素を追加したい開発者に最適です。

用途

  • ゲーム化アプリの報酬
  • 非表示コンテンツが表示される
  • インタラクティブプロモーション
  • デジタルスクラッチカード
  • ユーザー参加機能

主な機能

  • クロスプラットフォーム対応
  • カスタマイズ可能なこすり効果
  • タッチ操作の処理
  • スムーズなアニメーション
  • Flutter との簡単な統合
  • 設定可能なスクラッチの不透明度

適している対象

  • インタラクティブなUIを求めるアプリ開発者
  • ゲーム化プロジェクト
  • サプライズ要素を含むマーケティングキャンペーン
  • リベールメカニクスを備えた教育アプリ
  • シンプルな報酬ベースのアプリケーション

注意事項

  • 低性能デバイスでのパフォーマンスに影響を与える可能性があります
  • 高度なスクラッチパターンのカスタマイズが限定的
  • 高セキュリティなコンテンツの隠蔽には適していません
  • アクセシビリティを考慮した注意深い設計が必要です
  • 軽量なコンテンツと併用するのが最適です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

scratcher

Scratch card widget which temporarily hides content from the user.

Version

Demo

Features

  • Supported platforms:
    • Android
    • iOS
    • Web (CanvasKit only)
  • Cover content with full color or custom image
  • Track the scratch progress and threshold
  • Fully configurable

Getting started

  1. First thing you need to do is adding the scratcher as a project dependency in pubspec.yaml:
dependencies:
 scratcher: "^2.5.0"
  1. Now you can install it by running flutter pub get or through code editor.

Setting up

  1. Import the library:
import 'package:scratcher/scratcher.dart';
  1. Cover desired widget with the scratch card:
Scratcher(
  brushSize: 30,
  threshold: 50,
  color: Colors.red,
  onChange: (value) => print("Scratch progress: $value%"),
  onThreshold: () => print("Threshold reached, you won!"),
  child: Container(
    height: 300,
    width: 300,
    color: Colors.blue,
  ),
)

Properties

Property Type Description
child Widget Widget rendered under the scratch area.
enabled bool Whether new scratches can be applied.
threshold double Percentage level of scratch area which should be revealed to complete.
brushSize double Size of the brush. The bigger it is the faster user can scratch the card.
accuracy ScratchAccuracy Determines how accurate the progress should be reported. Lower accuracy means higher performance.
color Color Color used to cover the child widget.
image Image Image widget used to cover the child widget.
rebuildOnResize bool Determines if the scratcher should rebuild itself when space constraints change (resize).
onChange Function Callback called when new part of area is revealed (min 0.1% difference).
onThreshold Function Callback called when threshold is reached (only when defined).
onScratchStart Function Callback called when scratching starts.
onScratchUpdate Function Callback called during scratching.
onScratchEnd Function Callback called when scratching ends.

Programmatic access

You can control the Scratcher programmatically by assigning the GlobalKey to the widget.

final scratchKey = GlobalKey<ScratcherState>();

Scratcher(
  key: scratchKey,
  // remaining properties
)

After assigning the key, you can call any exposed methods e.g.:

RaisedButton(
  child: const Text('Reset'),
  onPressed: () {
    scratchKey.currentState.reset(duration: Duration(milliseconds: 2000));
  },
);
Method Description
reset Resets the scratcher state to the initial values.
reveal Reveals the whole scratcher, so than only original child is displayed.

Example Project

There is a crazy example project in the example folder. Check it out to see most of the available options.

Resources

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト