Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a new channel with stream_chat_flutter 9.x? #2080

Open
mauriziopinotti opened this issue Jan 11, 2025 · 1 comment
Open

How to create a new channel with stream_chat_flutter 9.x? #2080

mauriziopinotti opened this issue Jan 11, 2025 · 1 comment

Comments

@mauriziopinotti
Copy link

With stream_chat_flutter 8.x I used to create channels following the example app:

// in initState()
_channel = StreamChat.of(context).client.channel('messaging');

// then after the user selects the members for the new channel
  _channel = chatState.client.channel('messaging', extraData: {
    'members': [
      ..._selectedUsers.map((e) => e.id),
      chatState.currentUser!.id,
    ],
    'team': myteam,
  });

However, this no longer works with 9.x, I get

StreamChatNetworkError(code: 4, message: GetOrCreateChannel failed with error: "When using member based IDs specify at least 2 members", statusCode: 400, data: ErrorResponse(code: 4, message: GetOrCreateChannel failed with error: "When using member based IDs specify at least 2 members", statusCode: 400,

The example app does not have a create feature, how should channels be created in 9.x?

@szechyjs
Copy link

I too am having the issue. For me it is happening on the load of the new chat page, before I even call the api to create a new channel. It looks like the root is coming from loading an empty channel?

The create channel code is essentially copied directly from https://github.com/GetStream/flutter-samples/blob/develop/packages/stream_chat_v1/lib/pages/new_chat_screen.dart perhaps updating that to the latest version will solve this issue.

[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: StreamChatNetworkError(code: 4, message: GetOrCreateChannel failed with error: "When using member based IDs specify at least 2 members", statusCode: 400, data: ErrorResponse(code: 4, message: GetOrCreateChannel failed with error: "When using member based IDs specify at least 2 members", statusCode: 400, moreInfo: https://getstream.io/chat/docs/api_errors_response))
#0      StreamHttpClient.post (package:stream_chat/src/core/http/stream_http_client.dart:150:7)
<asynchronous suspension>
#1      ChannelApi.queryChannel (package:stream_chat/src/core/api/channel_api.dart:35:22)
<asynchronous suspension>
#2      Channel.query (package:stream_chat/src/client/channel.dart:1662:24)
<asynchronous suspension>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants