shake_event

A cross-platform shake event listener for Flutter applications.

Installation

First, add shake_event as a dependency in your pubspec.yaml file.

dependencies:
  shake_event: ^0.0.4

Example

import 'package:shake_event/shake_event.dart';

...
class _MyStatefulWidgetState extends State<HomeStatefulWidget> with ShakeHandler {

  @override
  void dispose() {
    resetShakeListeners();
    super.dispose();
  }
  
  @override
  shakeEventListener() {
    //DO ACTIONS HERE
    return super.shakeEventListener();
  }
  
  @override
  Widget build(BuildContext context) {
    startListeningShake(20); //20 is the default threshold value for the shake event
    ...
  }
}

Libraries

shake_event

Dart

VM

dart:ffi
Foreign Function Interface for interoperability with the C programming language. [...]

Web

dart:html
HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model). [...]
dart:js
Low-level support for interoperating with JavaScript. [...]
dart:js_util
Utility methods to efficiently manipulate typed JSInterop objects in cases where the name to call is not known at runtime. You should only use these methods when the same effect cannot be achieved with @JS annotations. These methods would be extension methods on JSObject if Dart supported extension methods.