Flutter Joystick

Pub License Pub likes Pub popularity Pub points Flutter platform

Buy Me A Coffee PayPal

A virtual joystick for Flutter applications.

Joystick

Joystick

Joystick(listener: (details) {
...
})

Joystick arguments:

ParameterDescription
listenercallback, which is called with period frequency when the stick is dragged. Listener parameter details contains the stick offset from the center of the base (can be from -1.0 to +1.0).
periodfrequency of calling listener from the moment the stick is dragged, by default 100 milliseconds.
modepossible directions mode of the joystick stick, by default all

Possible joystick modes:

ModeDescription
allallow move the stick in any direction: vertical, horizontal and diagonal
verticalallow move the stick only in vertical direction
horizontalallow move the stick only in horizontal direction
horizontalAndVerticalallow move the stick only in horizontal and vertical directions, not diagonal

Joystick Vertical Joystick Horizontal Joystick Horizontal And Vertical

Joystick Area

Joystick

JoystickArea allows to render a joystick anywhere in this area where user clicks.

JoystickArea(
  listener: (details) {
    ...
  },
  child: ...
)

JoystickArea has the same arguments as Joystick (listener, period, mode, etc.).

Additional JoystickArea arguments:

ParameterDescription
initialJoystickAlignmentInitial joystick alignment relative to the joystick area, by default Alignment.bottomCenter.
childThe child contained by the joystick area.

Customization

Square Joystick

Joystick and JoystickArea have additional arguments that allow to customize their appearance and behaviour.

ParameterDescription
baseWidget that renders joystick base, by default JoystickBase.
stickWidget that renders joystick stick, it places in the center of base widget, by default JoystickStick.
stickOffsetCalculatorCalculate offset of the stick based on the stick drag start position and the current stick position. The package currently only supports circle and rectangle joystick shapes. By default CircleStickOffsetCalculator.

Donate

If you found this package helpful and would like to thank me:

Buy Me A Coffee PayPal

Libraries

flutter_joystick