gamepad 0.1.0-dev+1

  • Installing
  • Versions
  • 36


UNRELEASED: Not currently ready for use.

A cross-platform Dart API for virtual and physical gamepad access in Dart.


  drivers/       | Libraries to initialize before using in a game
    browser.dart | Drivers that must be used within the browser
    flutter.dart | Drivers that must be used within Flutter[1]
    virtual.dart | Drivers that have no dependencies on a platform
  src/           | Internals. Should not be imported
  gamepad.dart   | Generic interfaces for use to build a game

[1]:, runs compiled Dart on Android/iOS


Loosely based on the W3C Gamepad API which is supported, but also with support for a combination of virtual gamepads (i.e. presents itself in the UI), for device features like accelerometers, and even for completely custom implementations (could be VR, remote, or something else).

There are a few concepts that should be understood when using the API below:

  • Gamepad: Frontend API that developers are expected to code against
  • Driver: Backend API that in turn is used by the package to produce gamepads
  • VirtualDriver: A synthetic backend that is implemented at runtime


One of the benefits of this library is that new gamepads can be created at runtime; this can be used to drive end-to-end testing of your application or even to create gamepads within the UI itself, or perhaps even controlled remotely by another device. The following is provided to help:

  • VirtualAxes: Can simulate multi-directional sticks
    • Directional: A mixin that provides simple directional support
  • VirtualButton: Can simulate a toggleable or pressable button
    • Toggle: A mixin that reports the button pressed until it is pressed again

An example of creating a virtual driver based on the W and S keys:

import 'dart:async';
import 'dart:html';

import 'package:gamepad/drivers/virtual.dart';

class WasdVirtualDriver extends VirtualDriver implements HasAxesSupport {
  Axes createAxes() => new WasdVirtualAxes(); 

class WasdVirtualAxes extends VirtualAxes<Element> with TriggerDirection {
  StreamSubscription _listener;

  Future<Null> activate(Element context) async {
    _listener = element.onKeyDown.listen((event) {
      if (event.key == 'W') {
      } else if (event.key =='S') {

  Future<Null> deactivate() async {
    await _listener.cancel();


Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  gamepad: "^0.1.0-dev+1"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

      import 'package:gamepad/gamepad.dart';
Version Uploaded Documentation Archive
0.1.0-dev+1 Dec 27, 2016 Go to the documentation of gamepad 0.1.0-dev+1 Download gamepad 0.1.0-dev+1 archive
0.1.0-dev Dec 27, 2016 Go to the documentation of gamepad 0.1.0-dev Download gamepad 0.1.0-dev archive


We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
89 / 100
Reflects how tidy and up-to-date the package is. [more]
45 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:gamepad/gamepad.dart.


  • Homepage does not exists.

    We were unable to access at the time of the analysis.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 3 errors 6 hints.

    Strong-mode analysis of lib/src/internal/async.dart failed with the following error:

    line: 7 col: 8
    Target of URI doesn't exist: 'package:collection/collection.dart'.

    Run dartfmt to format lib/src/drivers/api/axes.dart.

  • Package is getting outdated.

    The package was released 76 weeks ago.

  • Package is pre-release.

    Pre-release versions should be used with caution, their API may change in breaking ways.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use gamepad.dart.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.21.0 <2.0.0
meta ^1.0.4 1.1.5
quiver >=0.22.0 <0.25.0 0.24.0 0.29.0+1
Transitive dependencies
matcher 0.12.3
path 1.6.1
stack_trace 1.9.2
Dev dependencies
test ^0.12.18+1