패키지, 저장소 및 앱 카테고리 검색

flutter_joystick 표지
패키지 상세v0.2.3

flutter_joystick

Flutter 애플리케이션용 가상 조이스틱 위젯입니다. 매우 유연하고 사용자 정의가 가능합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.1만
좋아요
68
Pub 점수
160

패키지 설치

flutter pub add flutter_joystick

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Flutter용으로 특별히 설계된 매우 유연하고 사용자 정의 가능한 가상 조이스틱 위젯입니다. 안드로이드, iOS, 웹, 맥OS, 윈도우, 리눅스 등 여러 플랫폼에서 직관적인 터치 기반 제어 입력을 가능하게 합니다. 실시간 방향 피드백을 지원하며 앱의 미적 스타일과 쉽게 통합할 수 있습니다. 2D 게임, 시뮬레이터 또는 아날로그 스틱과 유사한 입력이 필요한 모든 애플리케이션에 적합합니다. 경량 설계로 저사양 장치에서도 부드러운 성능을 보장합니다.

사용 사례

  • 2D 모바일 게임
  • 웹 앱에서 게임 컨트롤러
  • 시뮬레이터 인터페이스
  • 사용자 정의 터치 컨트롤
  • 다중 플랫폼 게임 개발

주요 기능

  • 실시간 방향 입력
  • 매우 사용자 정의 가능한 외관
  • 크로스 플랫폼 호환성
  • 터치 기반 아날로그 제어
  • 사용자 정의 감도 및 사각지대

적합한 대상

  • 게임 개발자
  • 인터랙티브 앱 제작자
  • 크로스 플랫폼 프로젝트
  • 터치 컨트롤이 필요한 UI 디자이너
  • 아날로그 입력 프로토타이핑

고려 사항

  • 터치 이벤트를 수동으로 처리해야 합니다
  • 복잡한 게임 메커니즘을 처리하기 위해 추가 로직이 필요할 수 있습니다
  • 사용자 정의 스타일링은 Flutter 위젯에 익숙해야 합니다
  • 성능은 렌더링 복잡도에 따라 달라집니다
  • 고주파 입력 시나리오에 최적화되지 않음

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Flutter Joystick

Pub Version License Pub Likes Monthly Downloads Pub Points Flutter Platform

Buy Me A Coffee PayPal

📢 Follow for updates: t.me/pavelzaichyk_dev

Flutter Joystick is a virtual joystick package for Flutter applications that provides interactive joystick components for user interface design.

See Examples Google Play

Table of Contents

Joystick

Joystick

The Joystick widget is a virtual joystick that allows users to drag a stick within a defined area. You can customize its behavior and appearance. Here's how you can use it:

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

Joystick Arguments:

Parameter Description
listener A callback function that is invoked at a specified frequency (period) when the joystick stick is dragged. The listener parameter, details, provides the stick's offset from the center of the base (ranging from -1.0 to +1.0).
period (Optional) The frequency at which the listener callback is triggered from the moment the stick is dragged. The default is 100 milliseconds.
mode (Optional) The possible direction mode of the joystick stick. The default mode is all, allowing movement in any direction: vertical, horizontal, and diagonal.
includeInitialAnimation (Optional) Decides if the stick's initial movement animation should be included. By default [true].

This information clarifies the purpose and usage of each parameter for the Joystick widget.

Mode Description
all Allows movement of the joystick stick in any direction: vertical, horizontal, and diagonal.
vertical Restricts movement of the joystick stick to the vertical direction only.
horizontal Restricts movement of the joystick stick to the horizontal direction only.
horizontalAndVertical Restricts movement of the joystick stick to both horizontal and vertical directions, but not diagonal.

These modes define how the joystick stick can be moved, providing flexibility in tailoring the joystick's behavior to specific requirements.

Joystick Vertical Joystick Horizontal Joystick Horizontal And Vertical

Joystick Area

Joystick

The JoystickArea widget allows you to render a joystick anywhere within a designated area when the user interacts with it. It shares similar properties with the Joystick widget.

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

Additional JoystickArea Arguments:

Parameter Description
initialJoystickAlignment (Optional) Sets the initial alignment of the joystick within the joystick area. By default, it is aligned to Alignment.bottomCenter.
child (Optional) The widget that is contained within the joystick area, allowing you to place other elements or widgets alongside the joystick.

These arguments provide additional customization options for the JoystickArea widget, allowing you to control the initial alignment and include child widgets for a more versatile user interface.

Customization

Customization Options:

The Joystick and JoystickArea widgets are highly customizable, allowing you to tailor their appearance and behavior to fit your application's unique requirements. Below are the parameters you can adjust:

Parameter Description
base (Optional) The widget responsible for rendering the joystick's base. By default, it uses JoystickBase, but you can replace it with any widget to change its look. For example, you can use a custom image or a different shape.
stick (Optional) The widget that defines the appearance of the joystick stick. It is centered within the base widget. The default is JoystickStick, but you can customize it to be any widget, such as an icon, image, or animated widget.
stickOffsetCalculator (Optional) A function that determines the stick's offset based on the starting position of the stick drag and its current position. The package supports circular and rectangular shapes through CircleStickOffsetCalculator and RectangleStickOffsetCalculator respectively. You can create custom offset calculators for other shapes.

These customization parameters empower you to create distinctive and unique joystick experiences for your Flutter applications.

Snapping Feature:

The joystick supports a snapping feature that helps users by automatically aligning the stick to specific positions. This is controlled by the snappingThreshold parameter in both CircleStickOffsetCalculator and RectangleStickOffsetCalculator.

For circular joysticks (CircleStickOffsetCalculator), snapping occurs to:

  • Cardinal directions (0°, 90°, 180°, 270°)
  • Diagonal directions (45°, 135°, 225°, 315°)
  • The border of the circle when near the edge

For rectangular joysticks (RectangleStickOffsetCalculator), snapping occurs to:

  • The edges of the rectangle
  • The corners of the rectangle
  • The center (zero position)

The snappingThreshold value determines how close to a snap point the stick needs to be to trigger snapping. A value of 0.0 disables snapping, while larger values make snapping more aggressive.

Example usage:

Joystick(
  stickOffsetCalculator: CircleStickOffsetCalculator(snappingThreshold: 0.2),
  listener: (details) {
    // Handle joystick movement
  },
)

Examples:

Code Example
Joystick(
base: JoystickBase(
decoration: JoystickBaseDecoration(
middleCircleColor: Colors.red.shade400,
drawOuterCircle: false,
drawInnerCircle: false,
boxShadowColor: Colors.red.shade100,
),
),
stick: JoystickStick(
decoration: JoystickStickDecoration(
color: Colors.red,
),
),
listener: (details) {..},
)
Red Joystick
Joystick(
base: JoystickBase(
decoration: JoystickBaseDecoration(
color: Colors.black,
drawOuterCircle: false,
),
arrowsDecoration: JoystickArrowsDecoration(
color: Colors.blue,
),
),
listener: (details) {..},
)
Black Joystick
Joystick(
includeInitialAnimation: false,
base: JoystickBase(
decoration: JoystickBaseDecoration(
color: Colors.orange,
),
arrowsDecoration: JoystickArrowsDecoration(
color: Colors.grey,
enableAnimation: false,
),
),
stick: JoystickStick(
decoration: JoystickStickDecoration(
color: Colors.grey,
shadowColor: Colors.white.withOpacity(0.5)
),
),
listener: (details) {..},
)
Orange Joystick
Joystick(
base: JoystickSquareBase(),
stickOffsetCalculator: const RectangleStickOffsetCalculator(),
listener: (details) {..},
)
Square Joystick
Joystick(
stick: const CircleAvatar(
radius: 30,
child: FlutterLogo(size: 50),
),
base: Container(
width: 200,
height: 200,
decoration: const BoxDecoration(
color: Colors.grey,
shape: BoxShape.circle,
),
),
listener: (details) {..},
)
Custom Joystick

These examples highlight the flexibility of the joystick widget and provide a foundation for you to create your own customized joystick designs.

Donate

If you find this package helpful and would like to support its continued development, please consider making a donation. Your contributions are greatly appreciated and motivate the further enhancement of this and other plugins.

Donate Buy Me A Coffee PayPal

Your support helps in maintaining and improving this package, ensuring it remains up-to-date and useful for the community.

Thank you for your generosity!

Contributors

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트