Comments (14)
I was confused with that builder usage under MaterialApp and got rid of it, then I saw the same message error. I also use named routes.
It's not a clean solution, having the StreamChat initialized this early and at such high scope. Look forward to the better solution. And in the meantime, maybe you can comment in the sample code that builder:
was a temporary hack.
from stream-chat-flutter.
it is a really bad design choice I think. The chat itself would require authentication (need to get a token for a specific user min). And as far as I see, no plan to change it :/
I am building an app, not concentrated on chat but have chat with as an extra feature. Users should log in (this is where they will get the token with their id). When a first-time user opens the app, there is no user so no token.
Furthermore, users can log out and log in with different credentials. That time the client will be initialized with a different token.
Any suggestions on what can I do without putting StreamChat into the builder?
from stream-chat-flutter.
We added a navigator to make the StreamChat widget always be on top of the widget tree.
This approach is not the best and we should refactorize it finding a good compromise between usability and convenience.
The point is to make the user write as less code as possible to make a working app.
I'll think about it and hopefully come with a better solution.
For the moment you can try to use
Navigator.of(context, rootNavigator: true).pushNamed('/test'),
from stream-chat-flutter.
Are you trying to use StreamChat.of
in your new route?
The problem is that once you push a new route, the StreamChat
widget is not in your current widget tree anymore.
You may want to take a look at this https://stackoverflow.com/questions/49968817/flutter-inherited-widget-and-routes
A possible solution is to put the widget StreamChat
in the builder method of your MaterialApp
(like this answer https://stackoverflow.com/questions/49328362/get-access-to-the-context-of-inheritedwidget/49329255#49329255)
I think that's a better solution and in the next version, we can get rid of the additional Navigator (it was a workaround for this situation) suggesting to put the StreamChat
widget there.
from stream-chat-flutter.
after using the last version and put StreamChat
inside the builder, i can confirm that its working perfectly now, thank you for the quick response and maybe you can close this issue
from stream-chat-flutter.
now i get this error when i call StreamChat.of(context).client
:
You must have a StreamChat widget at the top of your widget tree
from stream-chat-flutter.
Could you try the last version using the StreamChat
widget in the builder method of the MaterialApp
?
from stream-chat-flutter.
Thank you for reporting the issue :)
from stream-chat-flutter.
I think that's true, but you can always just initialize the client and call client.setUser
deeper in the tree.
That was the simplest way to avoid to pass the StreamChat
widget on every Navigator.push
.
We're trying to find a better solution by the way.
from stream-chat-flutter.
I think that's true, but you can always just initialize the client and call
client.setUser
deeper in the tree.
That was the simplest way to avoid to pass theStreamChat
widget on everyNavigator.push
.We're trying to find a better solution by the way.
I think that's true, but you can always just initialize the client and call
client.setUser
deeper in the tree.
That was the simplest way to avoid to pass theStreamChat
widget on everyNavigator.push
.We're trying to find a better solution by the way.
@imtoori just wanted to check if this issue was resolved in the latest version.I am working on an application and dont want to initialise the stream client above authentication. I am getting the same error quoted above 'You must have a StreamChat widget at the top of your widget tree'
from stream-chat-flutter.
hey @siddhartha2000v this is not really an issue, but we've found a better solution than using the builder parameter of the MaterialApp and we're working on it
Can you give me more information about your issue?
I think the best way to use the StreamChat widget at the moment is using the builder parameter of the MaterialApp as you can see in our sample apps
The initialization using client.connectUser can even happen deeper in the widget tree, but the StreamChat widget would be better placed in there
from stream-chat-flutter.
Thanks for the update @imtoori. I am able to resolve the issue using the builder parameter in material app. However was looking for the update on better solution. Thanks for helping with current status anyways.
from stream-chat-flutter.
@barancezayirli : were you able to solve the issue ? I am in a similar situation right now . @imtoori : any solution for this ?
from stream-chat-flutter.
@luvishq what's your issue?
Putting the StreamChat
into the builder is always required, but you could call connectUser
even deeper in your tree.
Let me know your issue
from stream-chat-flutter.
Related Issues (20)
- Initial lag when using `StreamChatPersistenceClient` HOT 2
- Keyboard show on attachment file when attachment uploading HOT 1
- Notification in Background : Not Clickable HOT 6
- Deleting image message does not call delete the image from backend HOT 2
- Compatibility with flutter 3.19.0-pre HOT 4
- StreamChatNetworkError(code: 1000, message: Unauthorised, token not defined) after rebuild of StreamChat widget HOT 5
- Playback Discrepancy: Video Concludes Prematurely Compared to Scrubber Position HOT 1
- Sudden issue building. PersistentBottomSheetController showBottomSheet expected 0 arguments. HOT 1
- No instructions or warning that customAttachmentBuilders was removed HOT 1
- Add possibility to disable isOnlyEmoji functional HOT 3
- CreateDevice failed push provider with type firebase not found HOT 4
- stream channel bottom sheet Expected 0 type arguments HOT 2
- ../../../.pub-cache/hosted/pub.dev/stream_chat_flutter-5.3.0/lib/src/bottom_sheets/stream_channel_info_bottom_sheet.dart:322:1: Error: Expected 0 type arguments. HOT 7
- Add ability to mark a channel as unread HOT 4
- When user on android tries to download .doxc it downloads .zip folder HOT 2
- spaceBetweenActions not working HOT 4
- Special characters in filenames can lead to "AccessDeniedAccess denied" page on stream-io-cdn.com on iOS HOT 2
- StreamMediaAttachmentThumbnail is still inaccessible in 7.1.0 HOT 2
- support to customize the duration of scrolling to bottom HOT 2
- Reaction Picker Tail is always shown when the Reaction Picker is enabled in the default message widget HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stream-chat-flutter.