shake_detector 0.0.2 copy "shake_detector: ^0.0.2" to clipboard
shake_detector: ^0.0.2 copied to clipboard

a configurable package to detect shake gestures, using the sensors_plus package.

shake_detector #

A flutter package to detect phone shakes, upgraded version on shake.

Usage #

1. Use as Widget #

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('ShakeGesture Example')),
      body: Center(
        // The start.
        child: ShakeDetectWrap(
          onShake: () {
            ScaffoldMessenger.of(context).showSnackBar(
              const SnackBar(content: Text('Shake!')),
            );
          },
          child: const Center(
            child: OutlinedButton(
              onPressed: ShakeGestureTestHelperExtension.simulateShake,
              child: Text('Simulate Shake'),
            ),
          ),
        ),
		// The end.
      ),
    );
  }
}

2. Use as Listener #

To listen to phone shake:

ShakeDetector detector = ShakeDetector.autoStart(
    onPhoneShake: () {
        // Do stuff on phone shake
    }
);

OR

This will wait for user to call startListening() to start listening to phone shake:

ShakeDetector detector = ShakeDetector.waitForStart(
    onPhoneShake: () {
        // Do stuff on phone shake
    }
);

detector.startListening();

To stop listening:

detector.stopListening();
11
likes
0
pub points
92%
popularity

Publisher

verified publisherfolksable.com

a configurable package to detect shake gestures, using the sensors_plus package.

Repository (GitHub)
View/report issues

Topics

#sensors #shake #gestures

Funding

Consider supporting this project:

github.com

License

unknown (license)

Dependencies

flutter, sensors_plus

More

Packages that depend on shake_detector