shake_gesture 0.1.2 shake_gesture: ^0.1.2 copied to clipboard
shake_gesture is a Flutter package that provides a widget to detect shake gestures. It allows you to easily add shake detection to your Flutter app, which can be useful for a variety of purposes such [...]
import 'package:flutter/material.dart';
import 'package:shake_gesture/shake_gesture.dart';
import 'package:shake_gesture_test_helper/shake_gesture_test_helper.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key}) : super();
@override
Widget build(BuildContext context) {
return const MaterialApp(home: HomePage());
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('ShakeGesture Example')),
body: Center(
child: ShakeGesture(
onShake: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Shake!')),
);
},
child: const Center(
child: OutlinedButton(
onPressed: ShakeGestureTestHelperExtension.simulateShake,
child: Text('Simulate Shake'),
),
),
),
),
);
}
}