Comments (22)
Hi, @rlee1990. We will release a new version soon to make this a bit more clear.
Before calling .currentUser
you now need to set a user first, using streamClient.setUser(User('id', data: data), 'user-token');
from stream-feed-flutter.
@HayesGordon I did that and I still get a null user:
streamClient.setUser(
feed.User(id: u, data: {
'name': currentUser.data!.value.name,
'image': currentUser.data!.value.currentProfileImage
}),
feed.Token(currentUser.data!.value.currentToken!));
from stream-feed-flutter.
@sachaarbonel Any idea at to what the issue could be?
from stream-feed-flutter.
Hey sorry for the late response. As @HayesGordon said we did a change in this release (0.4.0) to be able to swap a User token at runtime (think of using a different profile for example) without instantiating StreamFeedClient again.
I think the reason why you have an error is that you try to setUser with data from currentUser (currentUser.data etc), but currentUser is not "set" yet. Maybe try to hardcode the value of name, image and token and see if it works
from stream-feed-flutter.
@sachaarbonel sorry for the confusion the currentUser in the code above is from Firebase which I get from a riverpod provider. I have confirmed that that information is coming in and that the setUser function is running.
from stream-feed-flutter.
oh, I see. Are you awaiting setUser
? It's a future now, so might be it
from stream-feed-flutter.
@sachaarbonel Yes I am.
I set the setUser up in a FutureProvider for Riverpod.
The watch it here:
return watch(streamUser).when(
data: (sUser) {
final streamClient = context.read(client);
switch (data.currentAccount) {
case 'personal':
return ScreenTypeLayout(
mobile: TabView(
currentUser: data,
streamClient: streamClient!,
),
);
default:
return ScreenTypeLayout(
mobile: TabView(
currentUser: data,
streamClient: streamClient!,
),
);
}
},
from stream-feed-flutter.
So sUser
is null inside your data callback?
from stream-feed-flutter.
@sachaarbonel nope this is what it returns:
I/flutter (25177): SUser data: StreamUser(ytmORLAvAiWvYGt2jyL2GzeENMc2_personal, 2021-08-19 16:59:15.430621Z)
from stream-feed-flutter.
It looks like the data might be coming back as null. I can call
final u = widget.streamClient
.user('${widget.user.uid}_${widget.user.currentAccount}');
With me putting in the username and trying to print u.data it returns null.
from stream-feed-flutter.
Any update on this?
from stream-feed-flutter.
Hey, @rlee1990 sorry I thought you meant User was null. The underlying data is. A workaround is to call profile
just after you setUser
from stream-feed-flutter.
@sachaarbonel when you say call profile is this a get stream function?
from stream-feed-flutter.
Nevermind
from stream-feed-flutter.
yes it's a method from StreamUser
await currentUser.profile()
from stream-feed-flutter.
I am still having an issue. @sachaarbonel is there an example anywhere so I can try to compare?
from stream-feed-flutter.
I tried a few more times and still get the same issue I don't think the current user is being set.
@sachaarbonel
from stream-feed-flutter.
Any update @HayesGordon or @sachaarbonel I can't seem to find a solution.
from stream-feed-flutter.
Hi @sachaarbonel any other recommendations?
from stream-feed-flutter.
It looks like the data might be coming back as null. I can call
final u = widget.streamClient .user('${widget.user.uid}_${widget.user.currentAccount}');
With me putting in the username and trying to print u.data it returns null.
@rlee1990 , After setting the user successfully, you should use
client.currentUser
to get the connected user.
client.user
is used to create a new user instance. that's why user.data
returns null.
from stream-feed-flutter.
Hi @xsahil03x Im still having the same issue
from stream-feed-flutter.
This is my riverpod provider:
final streamUser = FutureProvider.autoDispose((ref) async {
final streamClient = ref.read(client);
final currentUser = ref.watch(userAccount);
if (streamClient != null && currentUser.asData!.value.uid != null) {
print('Feed User set.');
var u =
'${currentUser.asData!.value.uid}_${currentUser.asData!.value.currentAccount}';
final user = await streamClient.setUser(
feed.User(
id: u,
),
feed.Token(currentUser.asData!.value.currentToken!));
await streamClient.currentUser!.profile();
return user;
}
return Future.value();
});
and the function where I first get a user:
widget.streamClient.currentUser!.get().then((value) {
var data = value.data;
setState(() {
image = data!['photo'] as String;
name = data['name'] as String;
});
fetchStories();
});
from stream-feed-flutter.
Related Issues (20)
- The documentation of `StreamFeedClient` is no correct HOT 1
- Bad State: Future already completed (dio package )
- [Help] limit of withRecentReactions HOT 3
- MultiProvider and Stream Feeds
- keepHistory parameter is missing from unfollowFeed in feed_bloc.dart (0.8.0)
- auth error
- Examples on using Stream Feeds using Stream Auth Firebase Function Extention
- The GenericFeed parsing problem HOT 3
- StateError when adding a child comment
- is this package still maintained?
- Unable to run with flutter v3 or v2 HOT 1
- ownChildren null
- Subscribing to multiple streams concurrently doesn't work
- "Missing user ID" when running the Flutter Example
- Faye: Invalid websocket close code used for Web
- Using paginatedParamsActivities getter outside stream_feed_flutter package
- Incorrect Types for height an width in OpenGraphData Model HOT 3
- Stream Feeds and Chat incompatible due to reliance on DIO package. HOT 3
- Update to support Dart 3.
- type '_Map<String, dynamic>' is not a subtype of type 'String' on client.user(123).update();
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-feed-flutter.