Migration from v1 🔄
This document highlights the most critical breaking changes to help you get started:
- Key updates to the core data models.
- Changes to the required parameters for the main
Chat
widget.
While this won’t cover every difference, understanding these core changes is the essential first step in adapting your v1 codebase.
Message Model Changes
Section titled “Message Model Changes”author
->authorId
: v2 now resolves user objects based on their ID.createdAt
: Type changed fromint
toDateTime
. It serializes to milliseconds UTC timestamp in JSON.status
: Replaced by a combination of optionalDateTime?
fields (deletedAt
,failedAt
,sentAt
,deliveredAt
,seenAt
,updatedAt
). The package calculates the status based on which fields are set, allowing for more granular control (useful for features like message history).
Image Message Specific Changes
Section titled “Image Message Specific Changes”name
: Removed.size
: Removed.uri
->source
: Renamed to highlight that the image source can be varied (local, remote, base64 string, etc.).
File Message Specific Changes
Section titled “File Message Specific Changes”size
: No longer required.uri
->source
: Renamed to highlight that the file source can be varied (local, remote, etc.).
Video Message Specific Changes
Section titled “Video Message Specific Changes”name
,size
: No longer required.uri
->source
: Renamed to highlight that the video source can be varied (local, remote, etc.).
User Model Changes
Section titled “User Model Changes”imageUri
->imageSource
: Renamed to highlight that the image source can be varied (local, remote, base64 string, etc.).firstName
,lastName
->name
: Simplified to a single field.createdAt
: Type changed fromint
toDateTime
. It serializes to milliseconds UTC timestamp in JSON.
Chat
Widget Parameter Changes
Section titled “Chat Widget Parameter Changes”messages
: Replaced by the requiredchatController
parameter. See the Architecture section for details on controller.onSendPressed
: No longer exists. The alternative is the optionalonMessageSent
callback.user
: Replaced by two required parameters:currentUserId
(UserID
): The ID of the currently logged-in user (equivalent to v1’suser.id
).resolveUser
(Future<User> Function(UserID id)
): An async function that takes a user ID and returns the correspondingUser
object. v2 uses IDs internally and calls this function (with in-memory caching) whenever user data is needed.
For anything else, please refer to the rest of this documentation, search or open an issue on GitHub.