InsanichessGame.fromJson constructor

InsanichessGame.fromJson(
  1. Map<String, dynamic> json
)

Creates new InsanichessGame object from json.

Implementation

InsanichessGame.fromJson(Map<String, dynamic> json)
    : id = json[InsanichessGameJsonKey.id],
      whitePlayer = InsanichessPlayer.fromJson(
          json[InsanichessGameJsonKey.whitePlayer]),
      blackPlayer = InsanichessPlayer.fromJson(
          json[InsanichessGameJsonKey.blackPlayer]),
      timeControl = InsanichessTimeControl.fromJson(
          json[InsanichessGameJsonKey.timeControl]),
      timesSpentPerMove = json[InsanichessGameJsonKey.timesSpentPerMove]
          .map<Duration>((e) => Duration(milliseconds: e))
          .toList(),
      remainingTimeWhite = Duration(
          milliseconds: json[InsanichessGameJsonKey.remainingTimeWhite]),
      remainingTimeBlack = Duration(
          milliseconds: json[InsanichessGameJsonKey.remainingTimeBlack]);