joystick 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

joystick #

A joystick widget for Flutter your apps.

It's design can be customized like background/icon color or opacity.

To set this joystick draggable is optional.

You can also use only vertical or horizontal direction arrows instead of all direction arrows.

[1.0.1] #

  • ReadMe is updated

[1.0.0] #

  • Migrated to stable version and a bug is fixed

[0.0.9] #

  • First initial release.

example/lib/main.dart

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


void main() => runApp(MyApp());

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

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int selectedGallery = 0;
  int selectedImage = 0;
  List<List<String>> galleryList = [
    [
      "assets/birds/b1.jpg",
      "assets/birds/b2.jpg",
      "assets/birds/b3.jpg",
      "assets/birds/b4.jpg",
    ],
    [
      "assets/cats/c1.jpg",
      "assets/cats/c2.jpg",
      "assets/cats/c3.jpg",
      "assets/cats/c4.jpg",
    ],
    [
      "assets/dogs/d1.jpg",
      "assets/dogs/d2.jpg",
      "assets/dogs/d3.jpg",
      "assets/dogs/d4.jpg",
    ]
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        decoration: BoxDecoration(
            image: DecorationImage(
                image: AssetImage(galleryList[selectedGallery][selectedImage]),
                fit: BoxFit.cover)),
        child: Joystick(
            size: 100,
            isDraggable: true,
            iconColor: Colors.amber,
            backgroundColor: Colors.black,
            opacity: 0.5,
            joystickMode: JoystickModes.all,
            onUpPressed: () {
              if (selectedGallery - 1 > 0)
                setState(() {
                  selectedGallery -= 1;
                });
            },
            onLeftPressed: () {
              if (selectedImage - 1 > 0)
                setState(() {
                  selectedImage -= 1;
                });
            },
            onRightPressed: () {
              if (selectedImage + 1 < galleryList[selectedGallery].length)
                setState(() {
                  selectedImage += 1;
                });
            },
            onDownPressed: () {
              if (selectedGallery + 1 < galleryList.length)
                setState(() {
                  selectedGallery += 1;
                });
            },
            onPressed: (_direction) {
              // print("pressed $_direction");
            }),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  joystick: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:joystick/joystick.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
41
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on May 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0

Health suggestions

Format lib/joystick.dart.

Run flutter format to format lib/joystick.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test