This is beta documentation for Stream Chat Flutter SDK v10. For the latest stable version, see the latest version (v9).

v9.0

v9.0 Migration Guide

This guide highlights the breaking changes introduced in v9.0 of the SDK. For questions or issues, file a GitHub issue.


Dependencies

To migrate to v9.0, update your pubspec.yaml:

dependencies:
  stream_chat_flutter: ^9.0.0

Breaking Changes

Refactored StreamAttachmentPickerController

The StreamAttachmentPickerController has been restructured to improve flexibility and support additional use cases like poll management.

Key Changes

  1. Value Type Update:

    • Previously managed a List<Attachment>.
    • Now manages an AttachmentPickerValue object, which includes:
      • attachments: A list of attachments.
      • poll: A new field for managing polls.
  2. Constructor Changes:

    • Added a new initialPoll parameter to set the initial poll.
    • The initialAttachments parameter now initializes the attachments field within AttachmentPickerValue.

Class Comparison

Old API:

class StreamAttachmentPickerController extends ValueNotifier<List<Attachment>> {
  StreamAttachmentPickerController({
    List<Attachment>? initialAttachments,
    int maxAttachmentSize,
    int maxAttachmentCount,
  });
}

New API:

class StreamAttachmentPickerController extends ValueNotifier<AttachmentPickerValue> {
  StreamAttachmentPickerController({
    Poll? initialPoll,
    List<Attachment>? initialAttachments,
    int maxAttachmentSize,
    int maxAttachmentCount,
  });
}

class AttachmentPickerValue {
  const AttachmentPickerValue({
    this.poll,
    this.attachments = const [],
  });

  final Poll? poll;
  final List<Attachment> attachments;

  AttachmentPickerValue copyWith({
    Poll? poll,
    List<Attachment>? attachments,
  });
}

Migration Steps

Updating Controller Usage
  • Old Approach: List<Attachment> manipulation.
  • New Approach: Use AttachmentPickerValue and its copyWith method.

Old Code:

final attachments = controller.value;
controller.value = [...attachments, newAttachment];

New Code:

final attachments = controller.value.attachments;
controller.value = controller.value.copyWith(
  attachments: [...attachments, newAttachment],
);
Managing Polls

Polls are now supported through the poll field.

Example:

// Setting a new poll
controller.poll = pollObject;

For additional support, visit our GitHub repository.