scratcher 0.0.1 scratcher: ^0.0.1 copied to clipboard
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,
),
),
),
],
),
),
);
}
}