Square class

A single square on a chess board or piece selector. Optionally contains a piece.

Inheritance

Constructors

Square({required int id, required GlobalKey<State<StatefulWidget>> squareKey, required Color colour, Widget? piece, String? symbol, bool draggable = true, double dragFeedbackSize = 2.0, Offset dragFeedbackOffset = const Offset(0.0, -1.0), void onTap(GlobalKey<State<StatefulWidget>>)?, void onDragCancel()?, Color? highlight, HighlightTheme? highlightTheme})

Properties

colour Color
Background colour of the square.
final
dragFeedbackOffset Offset
A vector to offset the position of dragged pieces by, relative to the size of the piece. No offset is recommended for web, and Offset(0,-1) for mobile, in which case the bottom of the piece will be anchored to the finger.
final
dragFeedbackSize double
The size of the piece being dragged will be multiplied by this. 1.5 is a good value for mobile, but 1.0 is preferable for web.
final
draggable bool
Whether the piece on this square can be dragged.
final
hashCode int
The hash code for this object.
no setterinherited
hasHighlight bool
Is this square highlighted?
no setter
hasPiece bool
Is there a piece on this square?
no setter
highlight Color?
The colour to use for highlight decoration, usually this is used for when a square is being highlighted for targeting. Leave as null for no highlight.
final
highlightTheme HighlightTheme
The theme to use when building piece/square highlights. See HighlightTheme for more details.
latefinal
id int
A unique id identifying this square within a Board or Hand. Usually dervied from the rank and file of the square within the board.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onDragCancel → (void Function()?)
A callback for when a drag action is cancelled.
final
onTap → (void Function(GlobalKey<State<StatefulWidget>>)?)
A callback for when the square is tapped, or a drag is started or finished.
final
piece Widget?
A widget that represents the piece on the square.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
squareKey GlobalKey<State<StatefulWidget>>
A key that will be given to the interior square widget. Used for getting the position of the square for promotion selector popups.
final
symbol String?
A single-character symbol representing the piece of the square. e.g. 'N', 'k'.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited