Got an answer for it.
if (body == null) {
if (typeOf<T>().isMarkedNullable) {
Resource.Success(null as T)
} else {
Resource.Error("APi responded with success but there is no data Available.")
}
}
I could use the isMarkedNullable
function to know if the value can be nullable