toJson method

  1. @override
Map<String, Object?> toJson()

Converts this object to json representation.

Implementation

@override
Map<String, Object?> toJson() {
  return <String, Object?>{
    InsanichessGameJsonKey.id: id,
    InsanichessGameJsonKey.whitePlayer: whitePlayer.toJson(),
    InsanichessGameJsonKey.blackPlayer: blackPlayer.toJson(),
    InsanichessGameJsonKey.timeControl: timeControl.toJson(),
    InsanichessGameJsonKey.timesSpentPerMove:
        timesSpentPerMove.map((Duration d) => d.inMilliseconds).toList(),
    InsanichessGameJsonKey.remainingTimeWhite:
        remainingTimeWhite.inMilliseconds,
    InsanichessGameJsonKey.remainingTimeBlack:
        remainingTimeBlack.inMilliseconds,
  };
}