Search packages, repositories and app categories

playing_cards cover
Package detailsv0.4.1+11

playing_cards

A rendering library for standard 52 card decks in your Flutter app. Use this package if you want to render good looking playing cards without too much fuss.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
3
Likes
145
Pub points
150

Install package

flutter pub add playing_cards

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter package that simplifies rendering visually appealing standard 52-card decks in your applications. Designed for game developers, it provides ready-to-use card widgets with proper styling and layout, enabling quick integration of card-based UIs without extensive custom coding. The library supports multiple platforms and ensures consistent, high-quality card visuals across devices.

Use cases

  • Card games development
  • Interactive deck simulations
  • Educational apps with cards
  • Digital poker or solitaire apps
  • UI prototyping with cards

Key features

  • Pre-built card widgets
  • Cross-platform support
  • High-resolution card designs
  • Easy integration with Flutter
  • Customizable card layouts

Suitable for

  • Game developers
  • UI designers
  • Educational app creators
  • Prototyping teams

Considerations

  • Limited to standard 52-card decks
  • No built-in game logic
  • Requires manual handling of card interactions
  • Not optimized for large card collections

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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.

Categories

Source repository

Projects using this package

No data available yet.