V2TimValueCallback<T>.fromJson constructor

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

Implementation

factory V2TimValueCallback.fromJson(Map<String, dynamic>? json) {
  if (T == V2TimMessage) {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : V2TimMessage.fromJson(json['data']) as T,
    );
  } else if (T == String) {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'],
    );
  } else if (T == bool) {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'],
    );
  } else if (T == int) {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'],
    );
  } else if (T == V2TimUserFullInfo) {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : V2TimUserFullInfo.fromJson(json['data']) as T,
    );
  } else if (T.toString() == 'List<V2TimUserFullInfo>') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : (json['data'] as List?)?.map((e) {
              return V2TimUserFullInfo.fromJson(e);
            })?.toList() as T?,
    );
  } else if (T.toString() == 'String') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'],
    );
  } else if (T.toString() == 'List<V2TimGroupInfo>') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : (json['data'] as List?)?.map((e) {
              return V2TimGroupInfo.fromJson(e);
            })?.toList() as T?,
    );
  } else if (T.toString() == 'List<V2TimGroupInfoResult>') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : (json['data'] as List?)?.map((e) {
              return V2TimGroupInfoResult.fromJson(e);
            })?.toList() as T?,
    );
  } else if (T.toString() == 'Map<String, String>') {
    Map<String, String> data = new Map<String, String>.from(json!['data']);
    return V2TimValueCallback(
      code: json['code'],
      desc: json['desc'],
      data: json['data'] == null ? null : data as T,
    );
  } else if (T.toString() == 'V2TimGroupMemberInfoResult') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : V2TimGroupMemberInfoResult.fromJson(json['data']) as T,
    );
  } else if (T.toString() == 'List<V2TimGroupMemberFullInfo>') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : (json['data'] as List?)?.map((e) {
              return V2TimGroupMemberFullInfo.fromJson(e);
            })?.toList() as T?,
    );
  } else if (T.toString() == 'List<V2TimGroupMemberOperationResult>') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : (json['data'] as List?)?.map((e) {
              return V2TimGroupMemberOperationResult.fromJson(e);
            })?.toList() as T?,
    );
  } else if (T.toString() == 'V2TimGroupApplicationResult') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : V2TimGroupApplicationResult.fromJson(json['data']) as T,
    );
  } else if (T.toString() == 'V2TimConversationResult') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : V2TimConversationResult.fromJson(json['data']) as T,
    );
  } else if (T.toString() == 'V2TimConversation') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : V2TimConversation.fromJson(json['data']) as T,
    );
  } else if (T.toString() == 'List<V2TimFriendInfo>') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : (json['data'] as List?)?.map((e) {
              return V2TimFriendInfo.fromJson(e);
            })?.toList() as T?,
    );
  } else if (T.toString() == 'List<V2TimFriendInfoResult>') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : (json['data'] as List?)?.map((e) {
              return V2TimFriendInfoResult.fromJson(e);
            })?.toList() as T?,
    );
  } else if (T.toString() == 'V2TimFriendOperationResult') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : V2TimFriendOperationResult.fromJson(json['data']) as T,
    );
  } else if (T.toString() == 'List<V2TimFriendOperationResult>') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : (json['data'] as List?)?.map((e) {
              return V2TimFriendOperationResult.fromJson(e);
            })?.toList() as T?,
    );
  } else if (T.toString() == 'V2TimFriendCheckResult') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : V2TimFriendCheckResult.fromJson(json['data']) as T,
    );
  } else if (T.toString() == 'List<V2TimFriendCheckResult>') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : (json['data'] as List?)?.map((e) {
              return V2TimFriendCheckResult.fromJson(e);
            })?.toList() as T?,
    );
  } else if (T.toString() == 'V2TimFriendApplicationResult') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : V2TimFriendApplicationResult.fromJson(json['data']) as T,
    );
  } else if (T.toString() == 'List<V2TimFriendGroup>') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : (json['data'] as List?)?.map((e) {
              return V2TimFriendGroup.fromJson(e);
            })?.toList() as T?,
    );
  } else if (T.toString() == 'List<V2TimMessage>') {
    return V2TimValueCallback(
      code: json!['code'],
      desc: json['desc'],
      data: json['data'] == null
          ? null
          : (json['data'] as List?)?.map((e) {
              return V2TimMessage.fromJson(e);
            })?.toList() as T?,
    );
  }

  return V2TimValueCallback(
    code: json!['code'],
    desc: json['desc'],
  );
}