dependencies:
stream_chat_flutter: ^9.0.0v9.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:
Breaking Changes
Refactored StreamAttachmentPickerController
The StreamAttachmentPickerController has been restructured to improve flexibility and support additional use cases like poll management.
Key Changes
Value Type Update:
- Previously managed a
List<Attachment>. - Now manages an
AttachmentPickerValueobject, which includes:attachments: A list of attachments.poll: A new field for managing polls.
- Previously managed a
Constructor Changes:
- Added a new
initialPollparameter to set the initial poll. - The
initialAttachmentsparameter now initializes theattachmentsfield withinAttachmentPickerValue.
- Added a new
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
AttachmentPickerValueand itscopyWithmethod.
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.