shake
3.0.0, released 2 years ago by joshi.dev
Detect phone shakes with direction, force, and noise filtering
What it does
The shake package listens to device sensors and triggers a callback when a shake is detected. It provides detailed information about the shake direction, force, and timestamp, and allows configuration of sensitivity and noise filtering.
AI-written summary of version 3.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- Implement shake-based actions in games or fitness apps
- Add security features that require physical shake gestures
- Create interactive UI effects that respond to device motion
Skip it when
- Running on platforms without sensor support (e.g., some web browsers)
- When you need continuous motion tracking rather than discrete shake events
Strengths
- Provides directional shake data via ShakeDirection enum
- Configurable sensitivity and noise filtering for reliable detection
- Simple callback API with no extra setup
Weaknesses
- Limited to mobile and web; no support for desktop platforms
- Requires sensors_plus dependency, which may add bundle size
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Add shake: ^3.0.0 to pubspec.yaml and import package:import 'package:shake/shake.dart'; No special permissions required.
```dart
import 'package:shake/shake.dart';
ShakeDetector detector = ShakeDetector.autoStart(
onPhoneShake: (ShakeEvent event) {
print('Direction: ${event.direction}');
print('Force: ${event.force}');
},
useFilter: true,
shakeThresholdGravity: 2.0,
shakeSlopTimeMS: 300,
shakeCountResetTime: 2000,
minimumShakeCount: 2,
);
```Alternatives
Packages that do the same job and could replace shake.
- app_settings
Open iOS and Android phone settings pages from a Flutter app.
89Compare - shake_gesture
Detect shake gestures in Flutter apps on Android and iOS.
84Compare - shake_detector
Detect phone shake gestures with pause/resume and optional widget wrapper
49Compare
Works with
Packages commonly used together with shake: ones it builds on, ones built on it, and its own family.