/ SDKs / Flutter
SDKs
Chat SDKs Flutter v4
Chat SDKs Flutter
Chat SDKs
Flutter
Version 4

Migration guide

Copy link

Sendbird Chat SDK v4 for Flutter has introduced enhancements and revisions from v3, including major breaking changes to streamline the code structure and enhance its scalability.

This page explains the breaking changes and provides a step-by-step guide to assist in transitioning from v3 to v4.


Requirements

Copy link

The minimum requirements for v4 are the following.

  • Flutter 3.7.0 or later
  • Dart 2.19.0 or later

Breaking changes

Copy link

The following breaking changes have been made to the Chat SDK v4 for Flutter.

  1. Renamed the core SDK class from SendbirdSdk to SendbirdChat.

  2. Renamed Options to SendbirdChatOptions.

  3. Renamed loadNext to next.

  4. Refactored the following params classes.

From v3To v4

GroupChannelParams

GroupChannelCreateParams
GroupChannelUpdateParams

OpenChannelParams

OpenChannelCreateParams
OpenChannelUpdateParams

UserMessageParams

UserMessageCreateParams
UserMessageUpdateParams

FileMessageParams

FileMessageCreateParams
FileMessageUpdateParams


  1. Renamed the following params classes.
From v3To v4

ScheduledUserMessageParams

ScheduledUserMessageCreateParams

ScheduledFileMessageParams

ScheduledFileMessageCreateParams


  1. Removed Event suffix from handler class names as shown below.
From v3To v4

ChannelEventHandler

GroupChannelHandler
OpenChannelHandler

ConnectionEventHandler

ConnectionHandler

SessionEventHandler

SessionHandler


  1. Added the following exception classes in v4.
v4

SendbirdException

LoginTimeoutException

AckTimeoutException

ConnectionRequiredException

ConnectionCanceledException

WebSocketFailedException

RequestFailedException

InvalidInitializationException

InvalidCollectionDisposedException

InvalidParameterException

NotSupportedException

QueryInProgressException

MarkAsReadRateLimitExceededException

MalformedDataException

BadRequestException

UnauthorizedException

InternalServerException

FileSizeLimitExceededException

SessionKeyRefreshFailedException

AccessTokenRevokedException

InvalidAccessTokenException

OperationCanceledException

InvalidMessageTypeException


  1. Added the following new collection classes in v4.
v4

ChannelContext

GroupChannelCollectionHandler

GroupChannelCollection

MessageCollectionHandler

MessageCollection

MessageContext


  1. Renamed the following enums.
From v3To v4

ScheduledMessageListOrder

ScheduledMessageListQueryOrder

MessageSendingStatus

SendingStatus

ConnectionState

MyConnectionState


  1. Removed the following enums from v3.
v3

ScheduledUserMessageStatus

MetaArrayUpdateMode

MessageType

UserEventCategory

MetaCounterMode

ChannelEventCategory

MessageQueryIncludeOption

ConnectionEventType

RestrictionType


  1. Added the following enums in v4.
v4

MembershipFilter

GroupChannelHiddenState

HiddenChannelFilter

GroupChannelListQueryOrder

GroupChannelListQueryType

GroupChannelListQuerySearchField



Migrating to v4

Copy link

The following guide covers the changes and key steps required during the migration from the Chat SDK v3 to v4.

Sendbird Chat SDK v4 will likely prevent your app from compiling until all migration tasks are complete and all errors are fixed. After fixing all the blocking errors, further work may be needed to remove warnings and align the SDK with your app again. We recommend you allow a generous timeline for the task.

Step 1 Update import statements

Copy link

Update all of import 'package:sendbird_sdk/sendbird_sdk.dart'; to import 'package:sendbird_chat_sdk/sendbird_chat_sdk.dart';.

Step 2 Refactor SendbirdSdk to SendbirdChat

Copy link

Replace all of SendbirdSdk with SendbirdChat.

Step 3 Refactor Options to SendbirdChatOptions

Copy link

Change Options to SendbirdChatOptions.

Step 4 Rename param classes

Copy link

Adjust all param classes according to the mapping table.

// Change UserMessageParams() to UserMessageCreateParams().

// v3
UserMessageParams(message: 'MESSAGE')

// v4
UserMessageCreateParams(message: 'MESSAGE')


// Change GroupChannelParams() to GroupChannelCreateParams().                    

// v3
GroupChannelParams()

// v4
GroupChannelCreateParams()

Step 5 Rename handler classes

Copy link

Update all handler class names by removing the 'Event' suffix. You can find the full list in number 6 of breaking changes.

// Change addChannelEventHandler() to addChannelHandler().

// v3
SendbirdSdk().addChannelEventHandler('UNIQUE_CHANNEL_EVENT_HANDLER', MyChannelEventHandler());

// v4
SendbirdChat.addChannelHandler('UNIQUE_CHANNEL_HANDLER', MyChannelHandler());

Step 6 Update query retrieval functions

Copy link

Switch all of loadNext to next.

// Change list query function loadNext() to next().

// v3
GroupChannelListQuery().loadNext();

// v4
GroupChannelListQuery().next();

Step 7 Update enum values

Copy link

Update enum values that were renamed, removed, or added as listed in numbers 9, 10, and 11 of breaking changes.

Step 8 Update variable and method names

Copy link

Update the variable and method names as shown in the table below. Changes are organized by v4 class names.

BaseChannel

Copy link
From v3To v4

creator

-

GroupChannel

Copy link

BaseMessage

Copy link

GroupChannelHandler

Copy link

GroupChannelChangeLogs

Copy link
From v3To v4

next

token

DoNotDisturb

Copy link
From v3To v4

enable

isDoNotDisturbOn

AppInfo

Copy link

FileInfo

Copy link

MessageChangeLogs

Copy link
From v3To v4

next

token

GroupChannelChangeLogsParams

Copy link

GroupChannelTotalUnreadChannelCountParams

Copy link

GroupChannelTotalUnreadMessageCountParams

Copy link

BaseMessageCreateParams

Copy link

BaseMessageFetchParams

Copy link

FileMessageCreateParams

Copy link

MessageListParams

Copy link
From v3To v4

customType

-

MessageRetrievalParams

Copy link
From v3To v4

replyToChannel

-

ScheduledFileMessageCreateParams

Copy link

ScheduledUserMessageCreateParams

Copy link

ThreadedMessageListParams

Copy link

TotalScheduledMessageCountParams

Copy link

UserMessageCreateParams

Copy link

GroupChannelListQuery

Copy link

OpenChannelListQuery

Copy link

PublicGroupChannelListQuery

Copy link

PreviousMessageListQuery

Copy link

ScheduledMessageListQuery

Copy link
From v3To v4

loadNext()

next()

PollListQuery

Copy link
From v3To v4

loadNext()

next()

PollVoterListQuery

Copy link
From v3To v4

loadNext()

next()

ApplicationUserListQuery

Copy link

BannedUserListQuery

Copy link
From v3To v4

loadNext()

next()

BlockedUserListQuery

Copy link
From v3To v4

loadNext()

next()

MemberListQuery

Copy link
From v3To v4

loadNext()

next()

MutedUserListQuery

Copy link
From v3To v4

loadNext()

next()

OperatorListQuery

Copy link
From v3To v4

loadNext()

next()

ParticipantListQuery

Copy link
From v3To v4

loadNext()

next()

BaseQuery

Copy link

Step 9 Update function parameter name

Copy link

Function parameter name when sending user message and file message has changed from onCompleted to handler.

// Change onCompleted to handler when sending user and file message.

// v3
channel.sendUserMessage(
  UserMessageParams(message: 'MESSAGE'),
  onCompleted: (message, error) {},
);

// v4
channel.sendUserMessage(
  UserMessageParams(message: 'MESSAGE'),
  handler: (message, e) {},
);

The migration process is now complete. We highly recommend a thorough review and testing of all app features to ensure seamless operation with the Sendbird Chat SDK v4.