appendUrl method

AccumulatedFileStream appendUrl({
  1. required String itemId,
  2. required String url,
  3. String? turnId,
  4. String? senderName,
})

Implementation

AccumulatedFileStream appendUrl({required String itemId, required String url, String? turnId, String? senderName}) {
  final current = upsert(itemId: itemId, turnId: turnId, senderName: senderName);
  final normalizedUrl = url.trim();
  final urls = current.urls.toList(growable: true);
  if (normalizedUrl.isNotEmpty && !urls.contains(normalizedUrl)) {
    urls.add(normalizedUrl);
  }
  final next = AccumulatedFileStream(
    itemId: current.itemId,
    turnId: current.turnId,
    status: 'in_progress',
    urls: List<String>.unmodifiable(urls),
    senderName: current.senderName,
  );
  _items[current.itemId] = next;
  return next;
}