GameState class

The complete, serializable snapshot of a Tetris game.

Constructors

GameState({required BoardState board, Tetromino? activePiece, Tetromino? ghostPiece, Tetromino? heldPiece, bool canHold = true, required List<TetrominoType> nextQueue, required ScoreState scoreState, required LevelState levelState, TetrisGameStatus status = TetrisGameStatus.idle})
const
GameState.fromJson(Map<String, dynamic> json)
factory

Properties

activePiece → Tetromino?
The falling piece, or null between pieces and when not playing.
final
board → BoardState
Locked cells.
final
canHold → bool
False after holding until the next piece spawns.
final
ghostPiece → Tetromino?
Where activePiece would land if hard-dropped.
final
hashCode → int
The hash code for this object.
no setterinherited
heldPiece → Tetromino?
The held piece, if any.
final
levelState → LevelState
final
nextQueue → List<TetrominoType>
Upcoming pieces, next first.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scoreState → ScoreState
final
status → TetrisGameStatus
final

Methods

copyWith({BoardState? board, Tetromino? activePiece, Tetromino? ghostPiece, Tetromino? heldPiece, bool? canHold, List<TetrominoType>? nextQueue, ScoreState? scoreState, LevelState? levelState, TetrisGameStatus? status, bool clearActive = false, bool clearGhost = false, bool clearHeld = false}) → GameState
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, dynamic>
toString() → String
A string representation of this object.
inherited

Operators

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