easter_egg_trigger 2.0.0
easter_egg_trigger: ^2.0.0 copied to clipboard
A widget that trigger an action when a secret gesture combination is detected
An Easter Egg trigger widget #
Here is full example :
import 'package:easter_egg_trigger/easter_egg_trigger.dart';
import 'package:flutter/material.dart';
import 'spackage:flutter/services.dart';
void main() {
runApp(const Material(child: MaterialApp(home: HomeView())));
}
class HomeView extends StatelessWidget {
const HomeView({super.key});
void _showCustomSnackBar(
BuildContext context, {
required Widget child,
required Color color,
}) =>
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: color,
behavior: SnackBarBehavior.floating,
duration: const Duration(seconds: 4),
dismissDirection: DismissDirection.down,
content: child,
),
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Home page')),
body: Center(
child: SizedBox(
width: 400,
child: Column(
spacing: 12.0,
children: [
EasterEggTrigger(
codes: const [
GestureEvent.swipeUp,
GestureEvent.swipeUp,
],
action: () => _showCustomSnackBar(
context,
color: Colors.purpleAccent,
child: const Text('OMFG You just found an obscure secret...'),
),
child: const _RoundedItem(color: Colors.purpleAccent, text: 'Swipe me up before you go go !'),
),
EasterEggTrigger(
codes: const [
GestureEvent.tap,
GestureEvent.tap,
GestureEvent.tap,
GestureEvent.tap,
GestureEvent.tap,
],
action: () => _showCustomSnackBar(
context,
color: Colors.orange,
child: const Text('You\'d better stop while you still can.'),
),
child: const _RoundedItem(color: Colors.orange, text: 'Tap me ! Again & again & again !!!'),
),
EasterEggTrigger(
action: () => _showCustomSnackBar(
context,
color: Colors.cyan,
child: const Text('You will regret it.'),
),
child: const _RoundedItem(color: Colors.cyan, text: '↑ ↑ ↓ ↓ ← → ← → Tap LongPress'),
),
EasterEggTrigger(
codes: const [
LogicalKeyboardKey.keyF,
LogicalKeyboardKey.keyU,
LogicalKeyboardKey.keyC,
LogicalKeyboardKey.keyK,
LogicalKeyboardKey.space,
LogicalKeyboardKey.keyP,
LogicalKeyboardKey.keyO,
LogicalKeyboardKey.keyU,
LogicalKeyboardKey.keyT,
LogicalKeyboardKey.keyI,
LogicalKeyboardKey.keyN,
LogicalKeyboardKey.keyE,
],
action: () => _showCustomSnackBar(
context,
color: Colors.red,
child: const Text(
'This plugin was made by KGB to find the IP address of enemy developers in order to eliminate them.'),
),
child: const _RoundedItem(color: Colors.red, text: 'Type "fuck poutine" (Indeed you need a keyboard)'),
),
EasterEggTrigger(
codes: const [
GestureEvent.tap,
LogicalKeyboardKey.keyT,
LogicalKeyboardKey.keyR,
LogicalKeyboardKey.keyU,
LogicalKeyboardKey.keyM,
LogicalKeyboardKey.keyP,
GestureEvent.tap,
],
action: () => _showCustomSnackBar(
context,
color: Colors.green,
child: const Text(
'The secret which is not really secret is that they\'re just assholes. Just like all dictators and killers that rules biggest countries and companies of our beloved world.'),
),
child: const _RoundedItem(color: Colors.green, text: 'Don\'t forget to tap Trump too...'),
),
EasterEggTrigger(
codes: const [
GestureEvent.tap,
GestureEvent.tap,
GestureEvent.tap,
GestureEvent.longPress,
GestureEvent.longPress,
GestureEvent.longPress,
GestureEvent.tap,
GestureEvent.tap,
GestureEvent.tap,
],
action: () => _showCustomSnackBar(
context,
color: Colors.yellow,
child: const Text(
'Anyway, what could we do ? Let\'s continue to keep our eyes closed while nature & people suffer.',
style: TextStyle(color: Colors.black),
),
),
child: const _RoundedItem(color: Colors.yellow, text: 'S.O.S'),
),
],
),
),
),
);
}
}
class _RoundedItem extends StatelessWidget {
final Color color;
final String text;
const _RoundedItem({required this.color, required this.text});
@override
Widget build(BuildContext context) => Material(
shape: RoundedRectangleBorder(
borderRadius: const BorderRadius.all(Radius.circular(16.0)),
side: BorderSide(color: color),
),
child: Padding(
padding: const EdgeInsets.all(32.0),
child: Text(text),
),
);
}