V2TimEventCallback<T>.fromJson constructor

V2TimEventCallback<T>.fromJson(
  1. Map<String, dynamic>? json
)

Implementation

factory V2TimEventCallback.fromJson(Map<String, dynamic>? json) {
  if (T == V2TimUserFullInfo) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimUserFullInfo.fromJson(json['data']) as T,
    );
  } else if (T == V2TimCallback) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimCallback.fromJson(json['data']) as T,
    );
  } else if (T == V2TimRecvC2cTextMessage) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimRecvC2cTextMessage.fromJson(json['data']) as T,
    );
  } else if (T == V2TimRecvC2cCustomMessage) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimRecvC2cCustomMessage.fromJson(json['data']) as T,
    );
  } else if (T == V2TimRecvGroupTextMessage) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimRecvGroupTextMessage.fromJson(json['data']) as T,
    );
  } else if (T == V2TimRecvGroupCustomMessage) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimRecvGroupCustomMessage.fromJson(json['data']) as T,
    );
  } else if (T == V2TimMessage) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimMessage.fromJson(json['data']) as T,
    );
  } else if (T.toString() == "List<V2TimMessageReceipt>") {
    return V2TimEventCallback(
      type: json!['type'],
      data: (json['data'] as List?)?.map((e) {
        return V2TimMessageReceipt.fromJson(e);
      })?.toList() as T?,
    );
  } else if (T.toString() == 'List<V2TimFriendApplication>') {
    return V2TimEventCallback(
      type: json!['type'],
      data: (json['data'] as List?)?.map((e) {
        return V2TimFriendApplication.fromJson(e);
      })?.toList() as T?,
    );
  } else if (T.toString() == 'List<String>') {
    return V2TimEventCallback(
      type: json!['type'],
      data: (json['data'] as List?)?.map((e) {
        return e as String;
      })?.toList() as T?,
    );
  } else if (T.toString() == 'List<V2TimFriendInfo>') {
    return V2TimEventCallback(
      type: json!['type'],
      data: (json['data'] as List?)?.map((e) {
        return V2TimFriendInfo.fromJson(e);
      })?.toList() as T?,
    );
  } else if (T.toString() == 'List<V2TimConversation>') {
    return V2TimEventCallback(
      type: json!['type'],
      data: (json['data'] as List?)?.map((e) {
        return V2TimConversation.fromJson(e);
      })?.toList() as T?,
    );
  } else if (T.toString() == 'List<V2TimGroupMemberInfo>') {
    return V2TimEventCallback(
      type: json!['type'],
      data: (json['data'] as List?)?.map((e) {
        return V2TimGroupMemberInfo.fromJson(e);
      })?.toList() as T?,
    );
  } else if (T == V2TimGroupMemberInfo) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimGroupMemberInfo.fromJson(json['data']) as T,
    );
  } else if (T == V2TimMemberEnter) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimMemberEnter.fromJson(json['data']) as T,
    );
  } else if (T == V2TimMemberLeave) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimMemberLeave.fromJson(json['data']) as T,
    );
  } else if (T == V2TimMemberInvited) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimMemberInvited.fromJson(json['data']) as T,
    );
  } else if (T == V2TimMemberKicked) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimMemberKicked.fromJson(json['data']) as T,
    );
  } else if (T == V2TimMemberInfoChanged) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimMemberInfoChanged.fromJson(json['data']) as T,
    );
  } else if (T == V2TimGroupCreated) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimGroupCreated.fromJson(json['data']) as T,
    );
  } else if (T == V2TimGroupDismissed) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimGroupDismissed.fromJson(json['data']) as T,
    );
  } else if (T == V2TimGroupRecycled) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimGroupRecycled.fromJson(json['data']) as T,
    );
  } else if (T == V2TimGroupInfoChanged) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimGroupInfoChanged.fromJson(json['data']) as T,
    );
  } else if (T == V2TimReceiveJoinApplication) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimReceiveJoinApplication.fromJson(json['data']) as T,
    );
  } else if (T == V2TimApplicationProcessed) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimApplicationProcessed.fromJson(json['data']) as T,
    );
  } else if (T == V2TimGrantAdministrator) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimGrantAdministrator.fromJson(json['data']) as T,
    );
  } else if (T == V2TimRevokeAdministrator) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimRevokeAdministrator.fromJson(json['data']) as T,
    );
  } else if (T == V2TimQuitFromGroup) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimQuitFromGroup.fromJson(json['data']) as T,
    );
  } else if (T == V2TimReceiveRestCustomData) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimReceiveRestCustomData.fromJson(json['data']) as T,
    );
  } else if (T == V2TimGroupAttributeChanged) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimGroupAttributeChanged.fromJson(json['data']) as T,
    );
  } else if (T == MessageProgress) {
    return V2TimEventCallback(
      type: json!['type'],
      data: MessageProgress.fromJson(json['data']) as T,
    );
  } else if (T == V2TimSignalFullinfo) {
    return V2TimEventCallback(
      type: json!['type'],
      data: V2TimSignalFullinfo.fromJson(json['data']) as T,
    );
  }

  return V2TimEventCallback(
    type: json!['type'],
    data: json['data'],
  );
}