typedef MessageBuilder = Widget Function(
BuildContext,
MessageDetails,
List<Message>,
MessageWidget defaultMessageWidget,
);
Migrating to 2.0 (Null-safety)
A Migration Guide For Switching To v2.0 Of The Flutter SDK
Overview
v2.0 of the Stream Chat Flutter SDK brings along several changes - primarily making the SDK null-safe. Null safety allows your apps to run faster, with fewer errors, and with less code.
Check this link for more about Null Safety in Flutter.
This guide is intended to enumerate and better explain the changes in the SDK.
The changes will be listed by package and a concise changelog will follow with more info.
Changelog of stream_chat_flutter
๐๏ธ Breaking Changes from 1.5.4
Migrate this package to null safety
Renamed
ChannelImage
toChannelAvatar
Updated
StreamChatThemeData.reactionIcons
to accept custom builderRenamed
ColorTheme
properties to reflect the purpose of the colorsColorTheme.black
->ColorTheme.textHighEmphasis
ColorTheme.grey
->ColorTheme.textLowEmphasis
ColorTheme.greyGainsboro
->ColorTheme.disabled
ColorTheme.greyWhisper
->ColorTheme.borders
ColorTheme.whiteSmoke
->ColorTheme.inputBg
ColorTheme.whiteSnow
->ColorTheme.appBg
ColorTheme.white
->ColorTheme.barsBg
ColorTheme.blueAlice
->ColorTheme.linkBg
ColorTheme.accentBlue
->ColorTheme.accentPrimary
ColorTheme.accentRed
->ColorTheme.accentError
ColorTheme.accentGreen
->ColorTheme.accentInfo
ChannelListCore
options property is removed in favor of individual propertiesoptions.state
->bool state
options.watch
->bool watch
options.presence
->bool presence
UserListView
options property is removed in favor of individual propertiesoptions.presence
->bool presence
Renamed
ImageHeader
toGalleryHeader
Renamed
ImageFooter
toGalleryFooter
MessageBuilder
andParentMessageBuilder
signature is now
The last parameter is the default MessageWidget
You can call .copyWith
to customize just a subset of properties
โ Added
Added video compress options (frame and quality) to MessageInput
TypingIndicator
now has a property called parentId
to show typing indicator specific to threads
#493: add support for MessageListView
header/footer
MessageWidget
accepts a userAvatarBuilder
Added pinMessage
UI support
Added MessageListView.threadSeparatorBuilder
property
Added MessageInput.onError
property to allow error handling
Added GalleryHeader
/GalleryFooter
theme classes
๐ Fixed
#483: Keyboard covers input text box when editing message
Modals
are shown using the nearest Navigator
to make using the SDK easier in a nested navigator use case
#484: messages donโt update without a reload
MessageListView
not rendering if the user is not a member of the channel
Fix MessageInput
overflow when there are no actions
Minor fixes and improvements
Migrating to 2.0 for stream_chat_flutter
If you are migrating your full Flutter project to null-safety, first make sure you follow the instructions from the official Null Safety migration guide.
To migrate to v2.0 for stream_chat_flutter
, first change the version of the package to the latest
null-safe version.
dependencies:
stream_chat_flutter: ^2.0.0
Upon doing this, all breaking changes from the package will take immediate effect. Here are steps to remedy the issues:
Replace the offending class names with the revised class names
ChannelImage
->ChannelAvatar
ImageHeader
->GalleryHeader
ImageFooter
->GalleryFooter
The new version comes with revised color names since the previous names do not suit light/dark mode nomenclature. Make sure any old colors used from theme are changed over to the new theme color names:
ColorTheme.black
->ColorTheme.textHighEmphasis
ColorTheme.grey
->ColorTheme.textLowEmphasis
ColorTheme.greyGainsboro
->ColorTheme.disabled
ColorTheme.greyWhisper
->ColorTheme.borders
ColorTheme.whiteSmoke
->ColorTheme.inputBg
ColorTheme.whiteSnow
->ColorTheme.appBg
ColorTheme.white
->ColorTheme.barsBg
ColorTheme.blueAlice
->ColorTheme.linkBg
ColorTheme.accentBlue
->ColorTheme.accentPrimary
ColorTheme.accentRed
->ColorTheme.accentError
ColorTheme.accentGreen
->ColorTheme.accentInfo
We decided to make messages easier to customize and now supply the default implementation of the messages in the builder - so you can now customize a single parameter without having to redo the entire implementation. Please reform your builders to take into account the new format:
typedef MessageBuilder = Widget Function(
BuildContext,
MessageDetails,
List<Message>,
MessageWidget defaultMessageWidget,
);
To tweak any of the default properties individually, you can use defaultMessageWidget.copyWith()
.
Changelog of stream_chat_flutter_core
๐๏ธ Breaking Changes from 1.5.3
- Migrate this package to null safety
channelsBloc.queryChannels()
,ChannelListCore
options param/property is removed in favor of individual params/propertiesoptions.state
->bool state
options.watch
->bool watch
options.presence
->bool presence
usersBloc.queryUsers()
,UserListCore
options param/property is removed in favor of individual params/propertiesoptions.presence
->bool presence
โ Added
- Monitor connection using
connectivity_plus
package
๐ Fixed
- Minor fixes
- Performance improvements
Migrating to 2.0 for stream_chat_flutter_core
If you are migrating your full Flutter project to null-safety, first make sure you follow the instructions from the official Null Safety migration guide.
To migrate to v2.0 for stream_chat_flutter_core
, first change the version of the package to the latest
null-safe version.
dependencies:
stream_chat_flutter_core: ^2.0.0
Upon doing this, all breaking changes from the package will take immediate effect. Here are steps to remedy the issue:
The major changes in stream_chat_flutter_core
consist of changing over from a map full of options
to a more type safe and sound approach by changing over to explicit parameters.
Change over Core widget implementations by using the explicit parameters instead of the options map. Use these explicit parameters in the widget constructor instead of the option keys:
options.state
->bool state
options.watch
->bool watch
options.presence
->bool presence
Change over query calls in the BLoCs in the same way (change from options map to explicit parameters in the constructor)
Changelog of stream_chat
๐๏ธ Breaking Changes from 1.5.3
- Migrate this package to null safety
ConnectUserWithProvider
now requirestokenProvider
as a required parameter. (Removed from the constructor)client.disconnect()
is now divided into two different functionsclient.closeConnection()
-> for closing user web socket connection.client.disconnectUser()
-> for disconnecting user and resetting client state.
client.devToken()
now returns a Token model instead of String.ApiError
is removed in favor ofStreamChatError
StreamChatError
-> parent type for all the stream errors.StreamWebSocketError
-> for user web socket related errors.StreamChatNetworkError
-> for network related errors.
client.queryChannels()
,channel.query()
options parameter is removed in favor of individual parametersoption.state
->bool state
option.watch
->bool watch
option.presence
->bool presence
client.queryUsers()
options parameter is removed in favor of individual parametersoption.presence
->bool presence
- Added typed filters
๐ Fixed
- #369: Client does not return without internet connection
- Several minor fixes
- Performance improvements
โ Added
- New Location
enum
is introduced for easily changing the client location/baseUrl. - New
client.openConnection()
andclient.closeConnection()
is introduced to connect/disconnect user WS connection. - New
client.partialUpdateMessage
andchannel.partialUpdateMessage
methods connectWebSocket
parameter in connect user calls to use the client in โconnection-lessโ mode.
๐ Changed
baseURL
is now deprecated in favor of using Location to change data location.
Migrating to 2.0 for stream_chat
If you are migrating your full Flutter project to null-safety, first make sure you follow the instructions from the official Null Safety migration guide. :::
To migrate to v2.0 for stream_chat
, first change the version of the package to the latest
null-safe version.
dependencies:
stream_chat: ^2.0.0
Upon doing this, all breaking changes from the package will take immediate effect. Here are steps to remedy the issues:
Change over the constructor of
connectUserWithProvider()
to the new format which hastokenProvider
as a required parameter.We added more nuance to
disconnectUser()
by adding two new methods - one to close the connection and the other to disconnect the user. This allows more fine-grained control of disconnection.client.closeConnection()
-> for closing user web socket connection.client.disconnectUser()
-> for disconnecting user and resetting client state.
We refactored how we handle errors - new error types are now introduced that replace ApiError.
StreamChatError
-> parent type for all the stream errors.StreamWebSocketError
-> for user web socket related errors.StreamChatNetworkError
-> for network related errors.
We changed over from a map full of options to a more type-safe and sound approach by changing over to explicit parameters.
Use these explicit parameters in the query parameters instead of the option keys:
client.queryChannels()
,channel.query()
options parameter is removed in favor of individual parametersoption.state
->bool state
option.watch
->bool watch
option.presence
->bool presence
client.queryUsers()
options parameter is removed in favor of individual parametersoption.presence
->bool presence
- We added type-safe filters to make filtering in the app easier. Change over the filters to the new implementation.
As an example, in the old app this filter:
filter: {
'members': {
'\$in': [StreamChat.of(context).user.id],
}
},
Would turn into:
filter: Filter.in_('members', [StreamChat.of(context).user.id])