shake 0.1.0 shake: ^0.1.0 copied to clipboard
A flutter package to detect phone shakes. Adjustable G-force and reset periods.
import 'package:flutter/material.dart';
import 'package:shake/shake.dart';
class DemoPage extends StatefulWidget {
@override
_DemoPageState createState() => _DemoPageState();
}
class _DemoPageState extends State<DemoPage> {
@override
void initState() {
super.initState();
ShakeDetector detector = ShakeDetector.autoStart(onPhoneShake: () {
// Do stuff on phone shake
});
// To close: detector.stopListening();
// ShakeDetector.waitForStart() waits for user to call detector.startListening();
}
@override
Widget build(BuildContext context) {
return Scaffold();
}
}