Map<String, Object?> toJson() { final nextBatch = this.nextBatch; return { 'chunk': chunk.map((v) => v.toJson()).toList(), if (nextBatch != null) 'next_batch': nextBatch, }; }