InsanichessChallenge.fromJson constructor

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

Creates new InsanichessChallenge from json.

Implementation

InsanichessChallenge.fromJson(Map<String, dynamic> json)
    : createdBy = json[InsanichessChallengeJsonKey.createdBy] == null
          ? null
          : InsanichessPlayer.fromJson(
              json[InsanichessChallengeJsonKey.createdBy]),
      timeControl = InsanichessTimeControl.fromJson(
          json[InsanichessChallengeJsonKey.timeControl]),
      preferColor = json[InsanichessChallengeJsonKey.preferColor] == 'w'
          ? insanichess.PieceColor.white
          : json[InsanichessChallengeJsonKey.preferColor] == 'b'
              ? insanichess.PieceColor.black
              : null,
      isPrivate = json[InsanichessChallengeJsonKey.isPrivate],
      status =
          challengeStatusFromJson(json[InsanichessChallengeJsonKey.status]);