Closed adityasethipsi closed 1 week ago
Please need support on this ASAP.
Hey @adityasethipsi π
This usually occurs in a situation when the StreamChat
widget is inaccessible by the Stream widget using the theme. Try checking through how you're using any navigation.
As for the sample you provided, the same works for me on 7.2.1 - here is a complete sample using your code if you want to run this yourself:
(Paste this in your main.dart and hit run)
// ignore_for_file: public_member_api_docs
import 'dart:async';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
/// Create a new instance of [StreamChatClient] passing the apikey obtained
/// from your project dashboard.
final client = StreamChatClient(
's2dxdhpxd94g',
logLevel: Level.OFF,
);
/// Set the current user and connect the websocket. In a production
/// scenario, this should be done using a backend to generate a user token
/// using our server SDK.
///
/// Please see the following for more information:
/// https://getstream.io/chat/docs/ios_user_setup_and_tokens/
await client.connectUser(
User(id: 'super-band-9'),
'''eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoic3VwZXItYmFuZC05In0.0L6lGoeLwkz0aZRUcpZKsvaXtNEDHBcezVTZ0oPq40A''',
);
runApp(
StreamChatPage(
client: client,
),
);
}
class StreamChatPage extends StatefulWidget {
final StreamChatClient client;
const StreamChatPage({
super.key,
required this.client,
});
@override
StreamChatPageState createState() => StreamChatPageState();
}
class StreamChatPageState extends State<StreamChatPage> {
late Channel channel;
StreamChatPageState();
@override
void dispose() {
channel.stopWatching();
channel.dispose();
super.dispose();
}
@override
void initState() {
super.initState();
channel = widget.client.channel(
'messaging',
id: 'flutterDevs',
);
}
@override
Widget build(BuildContext context) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
channel.watch();
});
final theme = ThemeData(
primarySwatch: Colors.green,
);
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData.light(),
darkTheme: ThemeData.dark(),
// themeMode: ThemeMode.dark,
supportedLocales: const [
Locale('en'),
Locale('hi'),
Locale('fr'),
Locale('it'),
Locale('es'),
],
builder: (context, a) => StreamChat(
client: widget.client,
child: a ?? Container(),
),
home: StreamChannel(
channel: channel,
child: ChannelPage(channel),
),
);
}
}
class ChannelPage extends StatefulWidget {
final Channel channel;
const ChannelPage(this.channel);
@override
_ChannelPageState createState() => _ChannelPageState();
}
class _ChannelPageState extends State<ChannelPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Expanded(
child: StreamMessageListView(
messageBuilder: (p0, p1, p2, defaultMessageWidget) {
return defaultMessageWidget.copyWith(
showDeleteMessage: true,
showEditMessage: true,
showReactionPicker: true,
showReactions: true,
showReplyMessage: true,
);
StreamMessageWidget;
},
),
),
const StreamMessageInput(
allowedAttachmentPickerTypes: [AttachmentPickerType.files],
),
],
),
);
}
}
const riveStreamReactionAnimations = [
RiveStreamReaction(
type: 'love',
artboard: 'love',
artboardHighlighted: 'love_highlight',
),
RiveStreamReaction(
type: 'like',
artboard: 'like',
artboardHighlighted: 'like_highlight',
),
RiveStreamReaction(
type: 'sad',
artboard: 'sad',
artboardHighlighted: 'sad_highlight',
),
RiveStreamReaction(
type: 'haha',
artboard: 'haha',
artboardHighlighted: 'haha_highlight',
),
RiveStreamReaction(
type: 'wow',
artboard: 'wow',
artboardHighlighted: 'wow_highlight',
),
];
@immutable
class RiveStreamReaction {
final String type;
final String artboard;
final String artboardHighlighted;
const RiveStreamReaction({
required this.type,
required this.artboard,
required this.artboardHighlighted,
});
}
class ReactionPicker extends StatelessWidget {
final Message message;
final void Function(String) onReactionTap;
const ReactionPicker({
Key? key,
required this.message,
required this.onReactionTap,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Wrap(
children: [
IconButton(
icon: const Text('π'),
onPressed: () => onReactionTap('smile'),
),
IconButton(
icon: const Text('π’'),
onPressed: () => onReactionTap('sad'),
),
IconButton(
icon: const Text('π'),
onPressed: () => onReactionTap('thumbs_up'),
),
IconButton(
icon: const Text('β€οΈ'),
onPressed: () => onReactionTap('heart'),
),
],
);
}
}
Let me know if there's something I'm missing here. If you're still getting this error after trying the sample above, please add the code you're using to connect and get until the messaging page. Thanks.
Closing this for now as I cannot replicate the bug with your code but feel free to reopen this if needed. Thanks!
Which packages are you using?
stream_chat_flutter
On what platforms did you experience the issue?
Web
What version are you using?
7.2.1
What happened?
When I long press on any message, then it shows this error as shown in SS.
Steps to reproduce
Supporting info to reproduce
// ignore_for_file: prefer-single-widget-per-file
Relevant log output
No response
Flutter analyze output
No response
Flutter doctor output
No response
Code of Conduct