轮盘包提供了一个简单、可自定义的轮盘控件,专为抽奖类游戏和奖励系统设计。基于 Flutter 构建,支持流畅的旋转动画,并可轻松集成到应用中,用于抽奖、竞赛或游戏化体验。该控件轻量级,可在 Android、iOS、Web、macOS、Windows 和 Linux 等主要平台上运行。对于希望快速添加交互式旋转轮盘而无需复杂实现的开发者来说,这是一个理想的选择。
适合场景
彩票抽奖
游戏化用户奖励
比赛奖品选择
交互式应用功能
用户参与工具
主要特点
平滑旋转动画
可自定义的轮盘扇区
跨平台兼容性
简单的 API 集成
可配置的旋转持续时间
适合对象
应用开发者构建游戏
创建推广活动的团队
带有互动元素的教育类应用程序
需要随机抽奖的应用
使用建议
超出基础样式的有限自定义
无内置音效
需要手动处理结果逻辑
未针对高频旋转进行优化
依赖外部状态管理来获取结果
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Project Status: Stable & Open for Contributions
This project has reached its primary goals. The author actively maintains it for compatibility with the latest SDKs and critical bug fixes, but is no longer actively developing new features.
Feature Requests: Suggestions are welcome! Please open an Issue for discussion.
Contributions: If you need a new feature, Pull Requests are highly encouraged and appreciated.
This is a Flutter library that provides a simple wheel widget for lottery usage.
Features
Quickly build customizable roulettes
Support roulettes with different sized parts based on specified weight
Easily control the roll animation and settle position
Support text, icons and images for roulette parts
There are various types of roulette provided by this package (text is optional):
Uniformed roulette:
Weight-based roulette:
IconData roulette (available in 0.1.4):
Image roulette (available in 0.1.5):
Getting started
Add this to your pubspec.yaml file:
dependencies:roulette:^1.0.0-rc.1
Note (v1.0.0-rc.1): The package no longer depends on package:flutter/material.dart.
RouletteStyle now requires centerStickerColor and dividerColor — use the deprecated
RouletteStyle.material() to keep the previous default look. It's highly recommend to specify the colors explicitly, the material ported version will be removed in future.
Roll infinitely before determine the result (available in 0.3.2)
You can also use rollInfinitely to roll infinitely until you call stop or rollTo method:
// Roll infinitely
controller.rollInfinitely();
// Getting the result value somewhere...try {
final result = await service.request()
final index = values.indexOf(result);
// Stop rolling and settle to index
controller.rollTo(index, offset: random.nextDouble());
} catch (e, st) {
// Or stop rolling immediately, stop with this method has no animation// controller.stop();
}
Please refer to API documentation for more details.
For more complete examples, please check the example app.
Legal Statement
The creators of this library do not endorse or encourage any illegal gambling activities. Please use this library responsibly and comply with all applicable laws in your local jurisdiction. The authors assume no liability for any misuse of this software.