Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
---
id: migration_guide_7_0
title: v7.0
slug: /guides/migration_guide_7_0/
---

This guide enumerates and better explains the SDK changes introduced in v7.

If you find any bugs or have any questions, please file an [issue on our GitHub repository](https://github.com/GetStream/stream-chat-flutter/issues). We want to support you as much as we can with this migration.

Code examples:

- See our [Stream Chat Flutter tutorial](https://getstream.io/chat/flutter/tutorial/) for an up-to-date guide using the latest Stream Chat version.
- See the [Stream Flutter Samples repository](https://github.com/GetStream/flutter-samples) with our full fledged messaging [sample application](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1).

Our documentation has also been updated to support v7, so all guides and examples will have updated code.

### Dependencies

To migrate to v7.0.0, update your `pubspec.yaml` with the correct Stream chat package you're using:

```yaml
dependencies:
stream_chat_flutter: ^7.0.0 # full UI, core and client packages
stream_chat: ^7.0.0 # client package
```

---

## What's New?

We improved the overall user experience of the Stream Chat Flutter SDK and added new features to make it easier to customize the SDK to your needs.

We've also fixed several bugs and improved the overall stability of the SDK.

Added support for `StreamMessageInput.contentInsertionConfiguration` to specify the content insertion configuration.

```dart
StreamMessageInput(
...,
contentInsertionConfiguration: ContentInsertionConfiguration(
onContentInserted: (content) {
// Do something with the content.
controller.addAttachment(...);
},
),
)
```
## Breaking changes

The following components have been removed in v7.0.0:

- `ChatPersistenceClient.getChannelStates.sort` has been removed in favor of `ChatPersistenceClient.getChannelStates.channelStateSort`.
```dart
/// BEFORE
chatPersistenceClient.getChannelStates(
...
sort: [SortOption('last_message_at')],
)

/// AFTER
chatPersistenceClient.getChannelStates(
...
channelStateSort: [SortOption('last_message_at')],
)
```
- `StreamChatClient.queryChannels.sort` has been removed in favor of `StreamChatClient.queryChannels.channelStateSort`.
```dart
/// BEFORE
streamChatClient.getChannelStates(
...
sort: [SortOption('last_message_at')],
)

/// AFTER
streamChatClient.getChannelStates(
...
channelStateSort: [SortOption('last_message_at')],
)
```
- `MessageWidget.customAttachmentBuilders` has been removed in favor of `MessageWidget.attachmentBuilders`.
```dart
/// BEFORE
MessageWidget(
customAttachmentBuilders: {
'image': (context, message, attachment) => // build image attachment,
},
...
)
```
```dart
/// AFTER
class CustomImageAttachmentBuilder extends StreamAttachmentWidgetBuilder {
@override
bool canHandle(
Message message,
Map<String, List<Attachment>> attachments,
) {
// Custom logic to check
// if the attachment can be handled by this builder
...
}

@override
Widget build(
BuildContext context,
Message message,
Map<String, List<Attachment>> attachments,
) {
// custom build implementation
...
}
}

MessageWidget(
attachmentBuilders: const [CustomImageAttachmentBuilder()],
...
)
```
- `RetryPolicy.retryTimeout` has been removed in favor of `RetryPolicy.delayFactor`.
- `StreamChatNetworkError.fromDioError` has been removed in favor of `StreamChatNetworkError.fromDioException`.
- `MessageSendingStatus` has been removed in favor of `MessageState`.
- `StreamChannelListController.sort` has been removed in favor of `StreamChannelListController.channelStateSort`.
- `ChannelPreview` has been removed in favor of `StreamChannelListTile`.
- `ChannelPreviewBuilder` has been removed in favor of `StreamChannelListViewIndexedWidgetBuilder`.
- `StreamUserItem` has been removed in favor of `StreamUserListTile`.
- `ReturnActionType` has been removed and no longer used.
- `StreamMessageInput.attachmentThumbnailBuilders` has been removed in favor of `StreamMessageInput.mediaAttachmentBuilder`.
- `MessageWidget.showReactionPickerIndicator` has been removed in favor of `MessageWidget.showReactionPicker`.
- `MessageWidget.bottomRowBuilder` has been removed in favor of `MessageWidget.bottomRowBuilderWithDefaultWidget`.
- `MessageWidget.deletedBottomRowBuilder` has been removed in favor of `MessageWidget.deletedBottomRowBuilderWithDefaultWidget`.
- `MessageWidget.usernameBuilder` has been removed in favor of `MessageWidget.usernameBuilderWithDefaultWidget`.
- `MessageWidget.showReactionPickerTail` has been removed in favor of `MessageWidget.showReactionPicker`.
- `MessageTheme.linkBackgroundColor` has been removed in favor of `MessageTheme.urlAttachmentBackgroundColor`.
- `showConfirmationDialog` has been removed in favor of `showConfirmationBottomSheet`.
- `showInfoDialog` has been removed in favor of `showInfoBottomSheet`.
- `wrapAttachmentWidget` has been removed in favor of `WrapAttachmentWidget`.
- `MessageListView.onMessageSwiped` parameter. Try wrapping the `MessageWidget` with a `Swipeable`, `Dismissible` or a custom widget to achieve the swipe to reply behaviour.
```dart
/// BEFORE
MessageListView(
onMessageSwiped: (Message message) => // handle swipe,
...
)

/// AFTER
MessageListView(
messageBuilder: (BuildContext context, Message message) =>
Swipeable(
key: ValueKey(message.id),
onSwiped: (_) => // handle swipe,
child: StreamMessageWidget(
message: message,
...
),
),
)
```
2 changes: 1 addition & 1 deletion packages/stream_chat_flutter/lib/src/stream_chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class StreamChat extends StatefulWidget {
/// Stream of connectivity result
/// Visible for testing
@visibleForTesting
final Stream<ConnectivityResult>? connectivityStream;
final Stream<List<ConnectivityResult>>? connectivityStream;

@override
StreamChatState createState() => StreamChatState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void main() {
'control test',
(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
home: StreamChat(
client: client,
streamChatThemeData: StreamChatThemeData.light(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void main() {

testWidgets('appears on tap', (tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
builder: (context, child) => StreamChat(
client: MockClient(),
child: child,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void main() {
void failFunction() => throw Exception('Something went wrong');

await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
builder: (context, child) => StreamChat(
client: MockClient(),
child: child,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void main() {
'it should show channel typing',
(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
home: StreamChat(
client: client,
child: StreamChannel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void main() {
'it should show channel typing',
(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
home: StreamChat(
client: client,
child: StreamChannel(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// ignore_for_file: public_member_api_docs, use_super_parameters

import 'package:connectivity_plus_platform_interface/connectivity_plus_platform_interface.dart';
import 'package:flutter/material.dart';

import 'mocks.dart';

class MaterialAppWrapper extends MaterialApp {
MaterialAppWrapper({
Key? key,
Expand All @@ -24,5 +27,7 @@ class MaterialAppWrapper extends MaterialApp {
navigatorObservers: [
if (navigatorObserver != null) navigatorObserver,
],
);
) {
ConnectivityPlatform.instance = MockConnectivityPlatform();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void main() {
StreamChat(
streamChatThemeData: theme,
client: client,
connectivityStream: Stream.value(ConnectivityResult.mobile),
connectivityStream: Stream.value([ConnectivityResult.mobile]),
child: StreamChannel(
showLoading: false,
channel: channel,
Expand Down Expand Up @@ -136,7 +136,7 @@ void main() {
home: StreamChat(
streamChatThemeData: theme,
client: client,
connectivityStream: Stream.value(ConnectivityResult.mobile),
connectivityStream: Stream.value([ConnectivityResult.mobile]),
child: StreamChannel(
showLoading: false,
channel: channel,
Expand Down Expand Up @@ -194,7 +194,7 @@ void main() {
home: StreamChat(
streamChatThemeData: theme,
client: client,
connectivityStream: Stream.value(ConnectivityResult.mobile),
connectivityStream: Stream.value([ConnectivityResult.mobile]),
child: StreamChannel(
showLoading: false,
channel: channel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ cool.''';
home: SimpleFrame(
child: StreamChat(
client: client,
connectivityStream: Stream.value(ConnectivityResult.wifi),
connectivityStream: Stream.value([ConnectivityResult.wifi]),
child: StreamChannel(
channel: channel,
child: Scaffold(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void main() {
StreamChat(
client: client,
streamChatThemeData: theme,
connectivityStream: Stream.value(ConnectivityResult.mobile),
connectivityStream: Stream.value([ConnectivityResult.mobile]),
child: Scaffold(
body: Center(
child: StreamReactionBubble(
Expand Down Expand Up @@ -69,7 +69,7 @@ void main() {
StreamChat(
client: client,
streamChatThemeData: StreamChatThemeData.fromTheme(themeData),
connectivityStream: Stream.value(ConnectivityResult.mobile),
connectivityStream: Stream.value([ConnectivityResult.mobile]),
child: ColoredBox(
color: Colors.black,
child: StreamReactionBubble(
Expand Down Expand Up @@ -106,7 +106,7 @@ void main() {
StreamChat(
client: client,
streamChatThemeData: StreamChatThemeData.fromTheme(themeData),
connectivityStream: Stream.value(ConnectivityResult.mobile),
connectivityStream: Stream.value([ConnectivityResult.mobile]),
child: ColoredBox(
color: Colors.black,
child: StreamReactionBubble(
Expand Down Expand Up @@ -151,7 +151,7 @@ void main() {
StreamChat(
client: client,
streamChatThemeData: StreamChatThemeData.fromTheme(themeData),
connectivityStream: Stream.value(ConnectivityResult.mobile),
connectivityStream: Stream.value([ConnectivityResult.mobile]),
child: ColoredBox(
color: Colors.black,
child: StreamReactionBubble(
Expand Down Expand Up @@ -196,7 +196,7 @@ void main() {
await tester.pumpWidgetBuilder(
StreamChat(
client: client,
connectivityStream: Stream.value(ConnectivityResult.mobile),
connectivityStream: Stream.value([ConnectivityResult.mobile]),
streamChatThemeData: StreamChatThemeData.fromTheme(themeData),
child: Scaffold(
body: Center(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void main() {
await tester.pumpWidgetBuilder(
StreamChat(
client: client,
connectivityStream: Stream.value(ConnectivityResult.mobile),
connectivityStream: Stream.value([ConnectivityResult.mobile]),
child: StreamChannel(
showLoading: false,
channel: channel,
Expand Down Expand Up @@ -146,7 +146,7 @@ void main() {
await tester.pumpWidgetBuilder(
StreamChat(
client: client,
connectivityStream: Stream.value(ConnectivityResult.mobile),
connectivityStream: Stream.value([ConnectivityResult.mobile]),
child: StreamChannel(
showLoading: false,
channel: channel,
Expand Down
13 changes: 13 additions & 0 deletions packages/stream_chat_flutter/test/src/mocks.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:connectivity_plus_platform_interface/connectivity_plus_platform_interface.dart';
import 'package:flutter/material.dart';
import 'package:mocktail/mocktail.dart';
import 'package:stream_chat_flutter/src/video/vlc/vlc_manager_desktop.dart';
Expand Down Expand Up @@ -67,3 +68,15 @@ class MockStreamMemberListController extends Mock
@override
PagedValue<int, Member> value = const PagedValue.loading();
}

class MockConnectivityPlatform extends ConnectivityPlatform {
@override
Future<List<ConnectivityResult>> checkConnectivity() {
return Future.value([ConnectivityResult.wifi]);
}

@override
Stream<List<ConnectivityResult>> get onConnectivityChanged {
return Stream.value([ConnectivityResult.wifi]);
}
}
4 changes: 4 additions & 0 deletions packages/stream_chat_flutter_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased

- 🛑 **BREAKING** Updated `connectivity_plus` library to `>= 6.0.0`.

## 8.0.0-beta.2

- Updated `stream_chat` dependency to [`8.0.0-beta.2`](https://pub.dev/packages/stream_chat/changelog).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class StreamChatCore extends StatefulWidget {
/// Stream of connectivity result
/// Visible for testing
@visibleForTesting
final Stream<ConnectivityResult>? connectivityStream;
final Stream<List<ConnectivityResult>>? connectivityStream;

@override
StreamChatCoreState createState() => StreamChatCoreState();
Expand Down Expand Up @@ -108,7 +108,7 @@ class StreamChatCoreState extends State<StreamChatCore>
/// The current user as a stream
Stream<User?> get currentUserStream => client.state.currentUserStream;

StreamSubscription<ConnectivityResult>? _connectivitySubscription;
StreamSubscription<List<ConnectivityResult>>? _connectivitySubscription;

var _isInForeground = true;
var _isConnectionAvailable = true;
Expand All @@ -121,13 +121,14 @@ class StreamChatCoreState extends State<StreamChatCore>
}

void _subscribeToConnectivityChange([
Stream<ConnectivityResult>? connectivityStream,
Stream<List<ConnectivityResult>>? connectivityStream,
]) {
if (_connectivitySubscription == null) {
connectivityStream ??= Connectivity().onConnectivityChanged;
_connectivitySubscription =
connectivityStream.distinct().listen((result) {
_isConnectionAvailable = result != ConnectivityResult.none;
_isConnectionAvailable = result.length > 1 ||
(result.length == 1 && result.first != ConnectivityResult.none);
if (!_isInForeground) return;
if (_isConnectionAvailable) {
if (client.wsConnectionStatus == ConnectionStatus.disconnected &&
Expand Down
Loading