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

패키지 상세v1.1.0

flutter_spinning_wheel

Flutter에서 회전 휠로 사용할 수 있는 사용자 지정 가능한 위젯입니다.

30일 다운로드
42
좋아요
89
Pub 점수
40

패키지 설치

flutter pub add flutter_spinning_wheel

패키지 개요

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

게임, 보상 및 추첨 메커니즘에 적합한 상호작용형 회전 휠을 만들기 위해 설계된 사용자 정의 가능한 Flutter 위젯입니다. 개발자는 사용자 지정 레이블, 색상 및 애니메이션을 가진 세그먼트를 정의할 수 있습니다. 부드러운 회전, 설정 가능한 속도 및 완료 시 이벤트 콜백을 지원합니다. 성능과 사용 편의성을 고려하여 제작되었으며, Flutter 앱에 원활하게 통합됩니다. 게임화 애플리케이션에서 몰입감 있는 사용자 경험을 제공하기에 이상적입니다.

사용 사례

  • 게임화된 사용자 인터페이스
  • 상품 추첨 또는 랄리 시스템
  • 인터랙티브 제품 데모
  • 보상 기반 앱 기능
  • 랜덤 선택을 포함한 교육 퀴즈

주요 기능

  • 사용자 정의 가능한 세그먼트 디자인
  • 부드러운 애니메이션 제어
  • 사용자 지정 가능한 회전 속도 및 지속 시간
  • 정지 시 이벤트 콜백
  • 동적 세그먼트 업데이트를 지원합니다
  • Flutter UI와의 간편한 통합

적합한 대상

  • 게임을 구축하는 앱 개발자
  • 인터랙티브 보상을 만드는 디자이너
  • 게임화를 구현하는 팀
  • 교육 앱 개발자
  • 인터랙티브 요소를 갖춘 마케팅 캠페인

고려 사항

  • 회전 로직의 수동 처리가 필요합니다
  • 제한된 내장 접근성 기능
  • 모든 플랫폼에서 터치 제스처에 대한 내장 지원이 없습니다
  • 많은 세그먼트가 있을 경우 성능이 달라질 수 있습니다
  • 고주파 회전에 최적화되지 않음

원본 README

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

flutter_spinning_wheel

Build Status License: MIT Pub

A customizable widget to use as a spinning wheel in Flutter.

Getting Started

Installation

Add


flutter_spinning_wheel : ^lastest_version

to your pubspec.yaml, and run

flutter packages get

in your project's root directory.

Basic Usage

Create a new project with command

flutter create myapp

Edit lib/main.dart like this:

import 'package:flutter/material.dart';

import 'package:flutter_circular_slider/flutter_circular_slider.dart';

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

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

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.blueGrey,
        body: Center(
          child: Container(child:
            SpinningWheel(
              Image.asset('assets/images/wheel-6-300.png'),
              width: 310,
              height: 310,
              dividers: 6,
              onEnd: _dividerController.add,
            ),
          ),
        ));
  }
}

You can replace the image with one of your preference.

Basic Game
Basic Wheel Game Wheel
Constructor
Parameter Default Description
image The image to be used as wheel.
dividers The number of divisions in the image. It's important that all divisions are equal.
height Height of the container that will display the wheel.
width Width of the container that will display the wheel.
initialSpinAngle 0.0 Initial rotation angle for the wheel, so the wheel could look initialy rotated.
spinResistance 0.5 From >0.0 to 1.0 will be used to calculate the speed and deceleration of the wheel.
canInteractWhileSpinning true If set to false, once the animation starts the user won't be able to stop it.
secondaryImage Secondary image that will be rendered on top of the wheel and won't be affected by the animation.
secondaryImageHeight Height for the secondary image.
secondaryImageWidth Width for the secondary image.
secondaryImageTop Used to fine tune the position of the secondary image. Otherwise it will be centered.
secondaryImageLeft Used to fine tune the position of the secondary image. Otherwise it will be centered.
onUpdate void onUpdate(int value) Callback function executed when the selected divider changes during the animation.
onEnd void onEnd(int value) Callback function executed when the animation stops.
shouldStartOrStop Stream to interact with the wheel, with double being pixelsPerSecond in axis y (default 8000)
Use Cases
Game
import 'dart:async';
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_spinning_wheel/flutter_spinning_wheel.dart';

void main() {
  SystemChrome.setEnabledSystemUIOverlays([]);
  runApp(MyApp());
}

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

class MyHomePage extends StatelessWidget {
  final StreamController _dividerController = StreamController<int>();

  dispose() {
    _dividerController.close();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(backgroundColor: Color(0xffDDC3FF), elevation: 0.0),
      backgroundColor: Color(0xffDDC3FF),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            SpinningWheel(
              Image.asset('assets/images/roulette-8-300.png'),
              width: 310,
              height: 310,
              initialSpinAngle: _generateRandomAngle(),
              spinResistance: 0.6,
              canInteractWhileSpinning: false,
              dividers: 8,
              onUpdate: _dividerController.add,
              onEnd: _dividerController.add,
              secondaryImage:
                  Image.asset('assets/images/roulette-center-300.png'),
              secondaryImageHeight: 110,
              secondaryImageWidth: 110,
            ),
            SizedBox(height: 30),
            StreamBuilder(
              stream: _dividerController.stream,
              builder: (context, snapshot) =>
                  snapshot.hasData ? RouletteScore(snapshot.data) : Container(),
            )
          ],
        ),
      ),
    );
  }

  double _generateRandomAngle() => Random().nextDouble() * pi * 2;
}

class RouletteScore extends StatelessWidget {
  final int selected;

  final Map<int, String> labels = {
    1: '1000\$',
    2: '400\$',
    3: '800\$',
    4: '7000\$',
    5: '5000\$',
    6: '300\$',
    7: '2000\$',
    8: '100\$',
  };

  RouletteScore(this.selected);

  @override
  Widget build(BuildContext context) {
    return Text('${labels[selected]}',
        style: TextStyle(fontStyle: FontStyle.italic, fontSize: 24.0));
  }
}

Game Wheel

카테고리

의존성

의존성 목록 1 개

소스 저장소

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

아직 데이터가 없습니다.