Coder Social home page Coder Social logo

ykw93 / flutter_hardware_buttons Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flutter-moum/flutter_hardware_buttons

0.0 1.0 0.0 114 KB

Flutter plugin for detecting all hardware buttons

License: MIT License

Kotlin 57.47% Swift 19.53% Objective-C 1.60% Dart 18.76% Ruby 2.64%

flutter_hardware_buttons's Introduction

hardware_buttons

Version GitHub license

A Flutter plugin for iOS and Android for detecting various hardware buttons.

Note: This plugin is still under development, and some APIs might not be available yet. Feedback and Pull Requests are most welcome!

Screenshots

screenshots

Features

  • Detect volume buttons
  • Detect home button
  • To be added...

Android specification

  • In order to listen to volume button events, this plugin inevitably requests for ACTION_MANAGER_OVERLAY_PERMISSION. This may surprise users, so we recommend notifying users beforehand.

iOS specification

  • No VOLUME_DOWN events are emitted when the volume is already at its minimum. VOLUME_UP events vice versa. On the other hand, events always occur whenever user presses the button on Android.

Usage

Import the package

To use this plugin, follow the plugin installation instructions.

Use the plugin

Add the following import to your Dart code:

import 'package:hardware_buttons/hardware_buttons.dart';

In order to listen to volume button events, use volumeButtonEvents.listen as below:

StreamSubscription _volumeButtonSubscription;

@override
void initState() {
  super.initState();
  _volumeButtonSubscription = volumeButtonEvents.listen((VolumeButtonEvent event) {
    // do something
    // event is either VolumeButtonEvent.VOLUME_UP or VolumeButtonEvent.VOLUME_DOWN
  });
}

@override
void dispose() {
  super.dispose();
  // be sure to cancel on dispose
  _volumeButtonSubscription?.cancel();
}

Similarly, you can listen to home button events using homeButtonEvents.listen.

Example

Find the example wiring in the example app.

API details

See the hardware_buttons.dart for more API details.

Issues and feedback

Please file issues to send feedback or report a bug. Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.