squares library

Classes

AnimatedDecorationContainer
A version of AnimatedContainer that only animates its decorations.
BackgroundConfig
Configuration for BoardBackground.
Board
The visual representation of the board. Can be used by itself to simply display a board, or in conjunction with BoardController or some other wrapper to manage its state and handle interactions.
BoardBackground
The background layer of a board. Contains coloured boxes, potentially with markers.
BoardBuilder
Builds a grid of widgets of size, according to builder.
BoardController
BoardOverlay
Builds a map of arbitrary children in a board arrangement, according to size and orientation. The keys of children should be square indices.
BoardPieces
The piece layer for a board. Contains pieces and empty boxes.
BoardSize
Specifies the dimensions of a board.
BoardState
A representation of a state of a board. Stores the contents of each square in board, the turn to move, orientation of the board, and highlights in lastFrom, lastTo and checkSquare.
BoardTargets
The target layer of a board. Contains the invisible widgets that handle gestures.
BoardTheme
Describes a colour scheme to be used by a Board.
ColourDragTargetFeedback
Displays simple containers with colours depending on whether a drag is valid or not.
CornersPainter
CrossPainter
CustomDragTargetFeedback
Build your own feedback!
DragTargetFeedback
Defines a builder function for a widget that will be displayed when a piece is dragged over a square.
Hand
A hand of pieces to drop from, such as in Crazyhouse.
InputOverlay
Builds GestureDetectors for each square on the board, handling some common gestures such as right clicks, long presses etc. Doesn't include everything that GestureDetector supports because it has literally 60+ parameters. It's easy enough to add more if you need them, and if you think one is a common enough use case, feel free to make a PR.
LabelConfig
Configuration for LabelOverlay.
LabelOverlay
An overlay that builds rank and file labels.
Marker
Data representation of a marker on the board, to simplify building them.
MarkerTheme
A theme that specifies a number of widget builder functions, used to define how various markers are drawn on the board.
Move
A representation of a move. from and to are square indices. promo and piece (both optional) are uppercase single character piece symbols. from can also be hand (-2), for drops originating off the board.
MoveAnimation
Builds a sliding animation for child, presumably a piece.
PartialMove
Used for dragging pieces.
Piece
PieceOverlay
Builds a map of pieces in a board arrangement, according to size and orientation, using pieceSet to determine the piece widgets.
PieceSelector
A popup widget used to select pieces to be used for promotion, or for gating.
PieceSelectorData
A configuration for a piece selector, i.e. for promotion or gating.
PieceSet
Used to define the widgets that will be built to represent pieces. Simply provide a map pieces of String keys and WidgetBuilder values. The keys should be uppercase for white pieces, and lowercase for black, e.g. a white pawn is 'P' and a black pawn is 'p'.
PlayerSet
Just a convenience class for configuring things that could apply to one player, neither or both.
PositionedPieceSelector
A piece selector, positioned relative to a board presumably behind it.
SimpleDragTargetFeedback
Displays single widgets depending on whether a drag is valid or not.
SquareNumberOverlay
An overlay that displays the square numbers. Primarily for debugging.
Squares

Enums

FileLabelPosition
HighlightType
Various types of highlights that might be present on the board.
PlayState
The core state of play, from a player's perpective.
PromotionBehaviour
Behaviour to use on promotion, regarding showing the piece selector.
RankLabelPosition

Constants

asciiALower → const int
asciiAUpper → const int
BLACK → const int
HAND → const int
WHITE → const int

Functions

alphaLowerLabel(int index) String
alphaUpperLabel(int index) String
generateHighlights({int? selection, int? target, required BoardState state, PlayState playState = PlayState.observing}) Map<int, HighlightType>
generateMarkers({HighlightType colour = HighlightType.selected, required BoardState state, required List<int> squares}) Map<int, Marker>
numericLabel(int index) String
pieceForPlayer(String piece, int player) String
playerForPiece(String piece, [int fallback = Squares.white]) int

Typedefs

IndexSquareBuilder = Widget? Function(int index, double squareSize)
A function to build a widget from index and squareSize.
IntCallback = int Function()
A function that returns an int.
Labeller = String Function(int)
MarkerBuilder = Widget Function(BuildContext context, double size, Color colour)
A function that builds a widget, given a context, size and colour.
SquareBuilder = Widget? Function(int rank, int file, double squareSize)
A function to build a widget from rank, file and squareSize.