GetStream / stream-chat-flutter

Flutter Chat SDK - Build your own chat app experience using Dart, Flutter and the Stream Chat Messaging API.
https://getstream.io/chat/sdk/flutter/
Other
881 stars 314 forks source link

Can't run tutorial with stream_chat_flutter: ^7.2.0 #1916

Closed ChefQ closed 1 month ago

ChefQ commented 1 month ago

Which packages are you using?

stream_chat_flutter

On what platforms did you experience the issue?

iOS

What version are you using?

^7.2.0

What happened?

I got the below error when i tried to follow the tutorial.

Error Error (Xcode): ../../.pub-cache/hosted/pub.dev/stream_chat_flutter_core-7.2.0/lib/src/stream_chat_core.dart:127:45: Error: A value of type 'Stream<List>' can't be assigned to a variable of type 'Stream?'.

Code: import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart';

void main() async { /// Create a new instance of [StreamChatClient] passing the apikey obtained from your /// project dashboard. final client = StreamChatClient( 'b67pax5b2wdq', logLevel: Level.INFO, );

/// Set the current user. 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/flutter-dart/tokens_and_authentication/?language=dart await client.connectUser( User(id: 'tutorial-flutter'), 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidHV0b3JpYWwtZmx1dHRlciJ9.S-MJpoSwDiqyXpUURgO5wVqJ4vKlIVFLSEyrFYCOE1c', );

/// Creates a channel using the type messaging and flutterdevs. /// Channels are containers for holding messages between different members. To /// learn more about channels and some of our predefined types, checkout our /// our channel docs: https://getstream.io/chat/docs/flutter-dart/creating_channels/?language=dart final channel = client.channel('messaging', id: 'flutterdevs');

/// .watch() is used to create and listen to the channel for updates. If the /// channel already exists, it will simply listen for new events. await channel.watch();

runApp( MyApp( client: client, channel: channel, ), ); }

class MyApp extends StatelessWidget { /// To initialize this example, an instance of [client] and [channel] is required. const MyApp({ Key? key, required this.client, required this.channel, }) : super(key: key);

/// Instance of [StreamChatClient] we created earlier. This contains information about /// our application and connection state. final StreamChatClient client;

/// The channel we'd like to observe and participate. final Channel channel;

@override Widget build(BuildContext context) { return MaterialApp( builder: (context, widget) { return StreamChat( client: client, child: widget, ); }, home: StreamChannel( channel: channel, child: const ChannelPage(), ), ); } }

/// Displays the list of messages inside the channel class ChannelPage extends StatelessWidget { const ChannelPage({ Key? key, }) : super(key: key);

@override Widget build(BuildContext context) { return Scaffold( appBar: const StreamChannelHeader(), body: Column( children: const [ Expanded( child: StreamMessageListView(), ), StreamMessageInput(), ], ), ); } }

Steps to reproduce

1. Go to https://getstream.io/chat/flutter/tutorial/
2. copy code under: Add Stream Chat to your Flutter application

Supporting info to reproduce

No response

Relevant log output

No response

Flutter analyze output

No response

Flutter doctor output

No response

Code of Conduct

IvanTrejoDev commented 1 month ago

I would try using the following dependencies. stream_chat_flutter: '7.2.0-hotfix.1' connectivity_plus: '5.0.2'

ChefQ commented 1 month ago

I'll try it next week thanks. Question: Is this new hotfix a response to my issue? Or did it always exist, and I was simply unaware of it?

ChefQ commented 1 month ago

Works like a charm!!!

@IvanTrejoDev

So without connectivity_plus: '5.0.2' it won't work!

Thanks a lot!!!

ChefQ commented 1 month ago

Now closing the issue!

IvanTrejoDev commented 1 month ago

I'll try it next week thanks. Question: Is this new hotfix a response to my issue? Or did it always exist, and I was simply unaware of it?

the hotfix has been around for a few weeks. It seems others had similar issues. Glad to help!