Closed RizanPSTU closed 3 years ago
Hey @RizanPSTU,
The event you mention is a health check and does not imply that the user is not connected / null. If your list of channels does not fetch the appropriate channels, can you provide a snippet of your ChannelListView code?
Thanks.
This is the channel list page. @deven98
import 'package:flutter/material.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
class TestChatList extends StatefulWidget {
const TestChatList({Key? key}) : super(key: key);
@override
_TestChatListState createState() => _TestChatListState();
}
class _TestChatListState extends State<TestChatList> {
@override
void initState() {
super.initState();
}
final Filter filter = Filter.and(
[Filter.in_('members', [])],
);
@override
Widget build(BuildContext context) {
return Scaffold(
body: ChannelsBloc(
child: ChannelListView(
filter: filter,
sort: [SortOption('last_message_at')],
pagination: PaginationParams(
limit: 30,
),
// channelPreviewBuilder: _channelPreviewBuilder,
pullToRefresh: false,
channelWidget: ChannelPage(),
),
),
);
}
}
class ChannelPage extends StatefulWidget {
const ChannelPage({
Key? key,
}) : super(key: key);
@override
_ChannelPageState createState() => _ChannelPageState();
}
class _ChannelPageState extends State<ChannelPage> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: ChannelHeader(),
body: Column(
children: <Widget>[
Expanded(
child: MessageListView(),
),
MessageInput(),
],
),
);
}
}
@RizanPSTU Your filter seems to be off, leading the list not to load.
Can you let me know what you are trying to do?
For example, if you are trying to search for channels with no members, you can do:
final Filter filter = Filter.equal('members', []);
I want to view the channels that I am a member of. Even tho if I comment out the filter it's not loading anything. @deven98
@override
Widget build(BuildContext context) {
return Scaffold(
body: ChannelsBloc(
child: ChannelListView(
// filter: filter,
sort: [SortOption('last_message_at')],
pagination: PaginationParams(
limit: 30,
),
// channelPreviewBuilder: _channelPreviewBuilder,
pullToRefresh: false,
channelWidget: ChannelPage(),
),
),
);
}
}
I have found the solution. I did wrong. I should use filter this way, @deven98 Thank you very much.
filter = Filter.and(
[
Filter.in_(
'members',
[StreamChat.of(context).user?.id ?? ""],
),
],
);
Happy to help :)
This should work too, btw:
filter = Filter.in_(
'members',
[StreamChat.of(context).user?.id ?? ""],
);
When I connect the user it gets connect but after some time. The user becomes null.
What package are you using? What version? stream_chat_flutter: ^2.0.0-nullsafety.4
What platform is it about?
To Reproduce Steps to reproduce the behavior:
Expected behavior I user should not be null
Screenshots
ℹ️ 📡 handle new event: {type: health.check, cid: *, channel_id: null, channel_type: null, connection_id: 60a775a4-0a03-1a67-0000-000000851041, created_at: 2021-05-30T07:45:58.682437Z, me: null, user: null, message: null, channel: null, member: null, reaction: null, total_unread_count: null, unread_channels: null, online: null, parent_id: null, is_local: false}
✓] Flutter (Channel stable, 2.2.0, on macOS 11.3.1 20E241 darwin-x64, locale en-GB) • Flutter version 2.2.0 at /Users/rizan/flutter • Framework revision b22742018b (2 weeks ago), 2021-05-14 19:12:57 -0700 • Engine revision a9d88a4d18 • Dart version 2.13.0
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/rizan/Library/Android/sdk • Platform android-S, build-tools 30.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.5, Build version 12E262 • CocoaPods version 1.10.1
[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
[✓] VS Code (version 1.56.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.22.0
[✓] Connected device (2 available) • Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator) • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.77 ! Error: Rafsan Uddin Beg’s iPhone is not connected. Xcode will continue when Rafsan Uddin Beg’s iPhone is connected. (code -13)