shake_event 0.0.9 copy "shake_event: ^0.0.9" to clipboard
shake_event: ^0.0.9 copied to clipboard

A shake event listener for Android and iOS. You can listen to shake events and set the threshold to define how precisely you want to listen to these events.

example/main.dart

import 'package:flutter/material.dart';
import 'package:shake_event/shake_event.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with ShakeHandler {
  @override
  void initState() {
    startListeningShake(20);
    //20 is the default threshold value for the shake event
    super.initState();
  }

  @override
  void dispose() {
    resetShakeListeners();
    super.dispose();
  }

  @override
  shakeEventListener() {
    //DO ACTIONS HERE
    return super.shakeEventListener();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold();
  }
}
8
likes
150
pub points
70%
popularity

Publisher

verified publisherdbilgin.com

A shake event listener for Android and iOS. You can listen to shake events and set the threshold to define how precisely you want to listen to these events.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, rxdart, sensors

More

Packages that depend on shake_event