scratcher 0.0.1 copy "scratcher: ^0.0.1" to clipboard
scratcher: ^0.0.1 copied to clipboard

outdated

Scratchable widget which temporarily hides content from user. Supports color & image area.

scratcher #

Scratchable widget which temporarily hides content from user. Supports color & image area.

Usage #

Example app can be found in (lib/example.dart)[lib/example.dart]

import 'package:flutter/material.dart';

import 'scratcher.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool isOver = false;
  double progress = 0;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: Stack(
          children: [
            Scratcher(
              brushSize: 30,
              threshold: 80,
              color: Colors.red,
              onChange: (value) {
                print("Progress: $value%");
                setState(() {
                  progress = value;
                });
              },
              onThreshold: () {
                print("Threshold reached.");
                setState(() {
                  isOver = true;
                });
              },
              child: Container(
                height: 700,
                width: double.infinity,
                child: Center(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Text(
                        isOver
                            ? "Congratulations, you won!"
                            : "Scratch the screen!",
                        textAlign: TextAlign.center,
                        style: TextStyle(fontSize: 24, color: Colors.amber),
                      ),
                    ],
                  ),
                ),
                color: Colors.grey,
              ),
            ),
            Positioned(
              bottom: 10,
              right: 10,
              child: Text(
                "${progress.toString()}%",
                textAlign: TextAlign.center,
                style: TextStyle(
                  fontSize: 40,
                  color: Colors.amberAccent,
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
417
likes
0
pub points
96%
popularity

Publisher

verified publishervaultomb.com

Scratchable widget which temporarily hides content from user. Supports color & image area.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on scratcher