shake_detector 0.1.0 copy "shake_detector: ^0.1.0" to clipboard
shake_detector: ^0.1.0 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(
          enabled: true,
          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();
9
likes
0
pub points
85%
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