搜索插件、代码仓与 APP 分类

playing_cards 封面
插件详情v0.4.1+11

playing_cards

一个用于在您的 Flutter 应用中渲染标准 52 张牌组的渲染库。如果您希望在无需过多麻烦的情况下呈现美观的扑克牌,请使用此包。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
3
喜欢数
145
Pub 分数
150

安装插件

flutter pub add playing_cards

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,可简化在您的应用程序中渲染视觉效果出色的标准 52 张牌牌组。专为游戏开发者设计,提供即用型卡片小部件,具有适当的样式和布局,可快速集成基于卡片的 UI,而无需进行大量自定义编码。该库支持多个平台,并确保在各种设备上保持一致且高质量的卡片视觉效果。

适合场景

  • 卡牌游戏开发
  • 交互式甲板模拟
  • 带卡片的教育类应用程序
  • 数字扑克或纸牌游戏应用
  • 使用卡片进行UI原型设计

主要特点

  • 预构建的卡片小部件
  • 跨平台支持
  • 高分辨率卡牌设计
  • 与 Flutter 的轻松集成
  • 可自定义的卡片布局

适合对象

  • 游戏开发者
  • UI设计师
  • 教育类应用程序开发者
  • 原型设计团队

使用建议

  • 限于标准52张牌牌组
  • 无内置游戏逻辑
  • 需要手动处理卡片交互
  • 未针对大型卡牌收藏进行优化

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

playing_cards

The playing_cards package for Flutter allows you to easily render playing cards from a standard 52 card deck. Good defaults are provided out of box, but full customization is possible if a style object is provided.

Getting Started

Here's a quick video overview if you don't like reading :-) https://www.youtube.com/watch?v=f9tOu972nhI

To import:

import 'package:playing_cards/playing_cards.dart';

And here is a simple usage to render a nine of clubs:

PlayingCardView(card: PlayingCard(Suit.clubs, CardValue.nine))

Here is an example of a fully styled deck:

// This style object overrides the styles for spades.
PlayingCardViewStyle myCardStyles = PlayingCardViewStyle(suitStyles: {
  Suit.spades: SuitStyle(
    builder: (context) => FittedBox(
          fit: BoxFit.fitHeight,
          child: Text(
            "💩",
            style: TextStyle(fontSize: 500),
          ),
        ),
    style: TextStyle(color: Colors.brown),
    cardContentBuilders: {
      CardValue.jack: (context) =>
          Image.asset("assets/jack_of_spades.png"),
      CardValue.queen: (context) =>
          Image.asset("assets/queen_of_spades.png"),
      CardValue.king: (context) =>
          Image.asset("assets/king_of_spades.png"),
    })
});
List<PlayingCard> deck = standardFiftyTwoCardDeck();
Container(
  height: 150,
  child: SingleChildScrollView(
    scrollDirection: Axis.horizontal,
    child: Row(
      children: deck.map((e) => PlayingCardView(card: e, style: myCardStyles)).toList(),
    ),
  ),
),

PlayingCardViewStyle also accepts a suitBesideLabel: true option to render the suit next to the rank, instead of below:

A flat fan widget is also provided for the common use cases of fanning cards out horizontally:

ShapeBorder shape = RoundedRectangleBorder(
  borderRadius: BorderRadius.circular(8),
  side: BorderSide(color: Colors.black, width: 1));
FlatCardFan(children: [
  PlayingCardView(
    card: PlayingCard(Suit.hearts, CardValue.ace),
    showBack: true,
    elevation: 3.0,
    shape: shape),
  PlayingCardView(
      card: PlayingCard(Suit.hearts, CardValue.ace),
      showBack: true,
      elevation: 3.0,
      shape: shape),
  PlayingCardView(
      card: PlayingCard(Suit.hearts, CardValue.ace),
      showBack: true,
      elevation: 3.0,
      shape: shape),
  PlayingCardView(
      card: PlayingCard(Suit.hearts, CardValue.ace),
      elevation: 3.0,
      shape: shape)
])

Jokers

Jokers are modelled as two joker CardValues (joker_1, joker_2) in a single joker Suit.

You can use the standardFiftyFourCardDeck() function in deck.dart to create a deck with two Jokers.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。