fromJson static method

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

Creates a new ChatMember object from a JSON object. This method decides which ChatMember subclass to use based on the status field.

Implementation

static ChatMember fromJson(Map<String, dynamic> json) {
  return switch (ChatMemberStatus.fromJson(json['status'])) {
    ChatMemberStatus.creator => ChatMemberOwner.fromJson(json),
    ChatMemberStatus.administrator => ChatMemberAdministrator.fromJson(json),
    ChatMemberStatus.member => ChatMemberMember.fromJson(json),
    ChatMemberStatus.restricted => ChatMemberRestricted.fromJson(json),
    ChatMemberStatus.left => ChatMemberLeft.fromJson(json),
    ChatMemberStatus.kicked => ChatMemberBanned.fromJson(json),
  };
}