Skip to content

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.

  • author -> authorId: v2 now resolves user objects based on their ID.
  • createdAt: Type changed from int to DateTime. It serializes to milliseconds UTC timestamp in JSON.
  • status: Replaced by a combination of optional DateTime? 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).
  • name: Removed.
  • size: Removed.
  • uri -> source: Renamed to highlight that the image source can be varied (local, remote, base64 string, etc.).
  • size: No longer required.
  • uri -> source: Renamed to highlight that the file source can be varied (local, remote, etc.).
  • name, size: No longer required.
  • uri -> source: Renamed to highlight that the video source can be varied (local, remote, etc.).
  • 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 from int to DateTime. It serializes to milliseconds UTC timestamp in JSON.
  • messages: Replaced by the required chatController parameter. See the Architecture section for details on controller.
  • onSendPressed: No longer exists. The alternative is the optional onMessageSent callback.
  • user: Replaced by two required parameters:
    • currentUserId (UserID): The ID of the currently logged-in user (equivalent to v1’s user.id).
    • resolveUser (Future<User> Function(UserID id)): An async function that takes a user ID and returns the corresponding User 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.