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
ChannelImagetoChannelAvatarUpdated
StreamChatThemeData.reactionIconsto accept custom builderRenamed
ColorThemeproperties to reflect the purpose of the colorsColorTheme.black->ColorTheme.textHighEmphasisColorTheme.grey->ColorTheme.textLowEmphasisColorTheme.greyGainsboro->ColorTheme.disabledColorTheme.greyWhisper->ColorTheme.bordersColorTheme.whiteSmoke->ColorTheme.inputBgColorTheme.whiteSnow->ColorTheme.appBgColorTheme.white->ColorTheme.barsBgColorTheme.blueAlice->ColorTheme.linkBgColorTheme.accentBlue->ColorTheme.accentPrimaryColorTheme.accentRed->ColorTheme.accentErrorColorTheme.accentGreen->ColorTheme.accentInfo
ChannelListCoreoptions property is removed in favor of individual propertiesoptions.state->bool stateoptions.watch->bool watchoptions.presence->bool presence
UserListViewoptions property is removed in favor of individual propertiesoptions.presence->bool presence
Renamed
ImageHeadertoGalleryHeaderRenamed
ImageFootertoGalleryFooterMessageBuilderandParentMessageBuildersignature 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.0Upon 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->ChannelAvatarImageHeader->GalleryHeaderImageFooter->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(),ChannelListCoreoptions param/property is removed in favor of individual params/propertiesoptions.state->bool stateoptions.watch->bool watchoptions.presence->bool presence
usersBloc.queryUsers(),UserListCoreoptions param/property is removed in favor of individual params/propertiesoptions.presence->bool presence
✅ Added
- Monitor connection using
connectivity_pluspackage
🐞 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.0Upon 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
ConnectUserWithProvidernow requirestokenProvideras 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.ApiErroris removed in favor ofStreamChatErrorStreamChatError-> 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 stateoption.watch->bool watchoption.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
enumis introduced for easily changing the client location/baseUrl. - New
client.openConnection()andclient.closeConnection()is introduced to connect/disconnect user WS connection. - New
client.partialUpdateMessageandchannel.partialUpdateMessagemethods connectWebSocketparameter in connect user calls to use the client in “connection-less” mode.
🔄 Changed
baseURLis 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.0Upon 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 hastokenProvideras 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 stateoption.watch->bool watchoption.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])- Overview
- Changelog of stream_chat_flutter
- 493: add support for MessageListView header/footer
- 483: Keyboard covers input text box when editing message
- 484: messages don’t update without a reload
- Migrating to 2.0 for stream_chat_flutter
- Changelog of stream_chat_flutter_core
- Migrating to 2.0 for stream_chat_flutter_core
- Changelog of stream_chat
- Migrating to 2.0 for stream_chat