fromJson method

  1. @override
UApplyWritesWrite fromJson(
  1. Map<String, dynamic> json
)

Implementation

@override
UApplyWritesWrite fromJson(Map<String, dynamic> json) {
  try {
    if (isCreate(json)) {
      return UApplyWritesWrite.create(
        data: const CreateConverter().fromJson(json),
      );
    }
    if (isUpdate(json)) {
      return UApplyWritesWrite.update(
        data: const UpdateConverter().fromJson(json),
      );
    }
    if (isDelete(json)) {
      return UApplyWritesWrite.delete(
        data: const DeleteConverter().fromJson(json),
      );
    }

    return UApplyWritesWrite.unknown(data: json);
  } catch (_) {
    return UApplyWritesWrite.unknown(data: json);
  }
}