搜尋套件、儲存庫與 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原型設計

主要特色

  • 預建構的卡片小部件
  • 跨平台支援
  • 高解析度卡牌設計
  • 與 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.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。