-
Notifications
You must be signed in to change notification settings - Fork 368
Closed
Description
Which packages are you using?
stream_chat_flutter
On what platforms did you experience the issue?
Android, iOS
What version are you using?
stream_chat_flutter: ^9.14.0
What happened?
When using StreamChannel, the widget immediately renders its child even if the underlying channel's cid is still loading . Since _maybeInitChannel() exits early when channel.cid == null, the FutureBuilder completes and renders the child prematurely—before the channel is ready.
Steps to reproduce
Create a Channel with a null cid (e.g., when only the channel members is known, but the CID isn't yet assigned).
Pass the channel to a StreamChannel.
Observe that the child widget is rendered immediately.
the child starts depending on the channel state, causing null errors or invalid behavior.
Supporting info to reproduce
Future<void> _maybeInitChannel() async {
if (channel.cid == null) return; // <-- Returns immediately
if (channel.state == null) await channel.watch();
}
And in build():
return FutureBuilder<void>(
future: _channelInitFuture,
builder: (context, snapshot) {
if (snapshot.hasError) {
return widget.errorBuilder(context, snapshot.error!, snapshot.stackTrace);
}
if (snapshot.connectionState != ConnectionState.done) {
if (widget.showLoading) return widget.loadingBuilder(context);
}
return widget.child; // <-- Rendered even if cid is null
},
);
Relevant log output
════════ Exception caught by widgets library ═══════════════════════════════════
Channel null is not initialized
'package:stream_chat_flutter/src/channel/stream_channel_avatar.dart':
Failed assertion: line 61 pos 11: 'channel.state != null'
Flutter analyze output
Flutter doctor output
Code of Conduct
- I agree to follow this project's Code of Conduct