How to get a stream value and then call another stream based on the previous value using Flutter with firestoreHow to build Flutter widget based on two Firestore collectionsFirebase realtime database deep query returns nullFlutter : Bad state: Stream has already been listened toHow to query firestore document inside streambuilder and update the listviewFlutter Firestore NoSuchMethodError: The method 'get' was called on nullFlutter Firestore save value as stringHow to get the number of Firestore documents in flutterFlutter Firestore query to return listFlutter & Firestore - Update never stops (switch from one value to another)How I can put Widget above Widget using List<Widget> widget in Flutter?Flutter firestore listen is interrupting by previous page firestore listen

Is a Lisp program in both prog-mode and lisp-mode?

What explains 9 speed cassettes price differences?

The monorail explodes before I can get on it

Bronze Age Underwater Civilization

What is temperature on a quantum level

Why are Hobbits so fond of mushrooms?

Were there any new Pokémon introduced in the movie Pokémon: Detective Pikachu?

How do you tell if your Nintendo Switch is the primary console?

Who Can Help Retag This?

Why did my rum cake turn black?

Is Prophet from Facebook any different from a linear regression?

'rm' (delete) thousands of files selectively

What would be the ideal melee weapon made of "Phase Metal"?

Keep milk (or milk alternative) for a day without a fridge

Where is the USB2 OTG port on the RPi 4 Model B located?

What is this welding tool I found in my attic?

Is an acid a salt or not?

Repeating redundant information after dialogues, to avoid or not?

How the name "craqueuhhe" is read

Correlation of independent random processes

Does Google Maps take into account hills/inclines for route times?

Are randomly-generated passwords starting with "a" less secure?

What are the steps/action plan to introduce Test Automation in a company?

Redirect https to fqdn



How to get a stream value and then call another stream based on the previous value using Flutter with firestore


How to build Flutter widget based on two Firestore collectionsFirebase realtime database deep query returns nullFlutter : Bad state: Stream has already been listened toHow to query firestore document inside streambuilder and update the listviewFlutter Firestore NoSuchMethodError: The method 'get' was called on nullFlutter Firestore save value as stringHow to get the number of Firestore documents in flutterFlutter Firestore query to return listFlutter & Firestore - Update never stops (switch from one value to another)How I can put Widget above Widget using List<Widget> widget in Flutter?Flutter firestore listen is interrupting by previous page firestore listen






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm trying to get the Ids of users i'm following from a firestore stream and then call another stream with the posts of my followings with the ids from previously.



I don't know if this is the right way to architect it and if so how to implement it with flutter.. I've been trying streamBuilder for the first call, but I don't know how to make the second stream call with a list of ids.



The function that I used to get the followings Ids



Stream<QuerySnapshot> followingUsersContent(String uid)
return _firestore.collection("following").document(uid).collection("userFollowing").snapshots();



and to get their posts:



Stream<DocumentSnapshot> myContentList(String userId) 
return _firestore.collection("posts").document(userId).collection("userPosts").document().snapshots();



This is how I retrieve the first list of Id's from the widget:



postWidget()
return Container(
child: StreamBuilder<QuerySnapshot>(
stream: usersContentProvider.followingUsersContent(profileId),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot)
if (!snapshot.hasData)
return Text("There's no data");


if (snapshot.hasData)

List<DocumentSnapshot> docs = snapshot.data.documents;

List<UserFollowing> userInfoList = usersContentProvider.getFollowingsUidToList(docs);

return testUserID(userInfoList);


,
),
);



Widget testUserID(List<UserFollowing> userInfoList)
return Container(
child: Expanded(
child: ListView.builder(
itemCount: userInfoList.length,
itemBuilder: (BuildContext context, i)

return Text(userInfoList[i].uid ?? "There's no data", style: TextStyle(color: Colors.red),);

),
),
);



So far so good everything is fine.



Now should I put another stream builder inside the listView.Builder() "I don't think it's a good idea".. because it is retrieving a list of uid with the (itemBuilder context, i). Or is there a better way to call the stream with all the uids I have.
Ps the uids are stored in the UserFollowing model:



class UserFollowing
final String _uid;


UserFollowing(this._uid);

String get uid => _uid;



and stored from here:



List getFollowingsUidToList(List<DocumentSnapshot> docList)
if (docList != null)
List<UserFollowing> followingUidsList = [];
docList.forEach((document)
String uid = document.data["uid"];

UserFollowing userPost = UserFollowing(uid);
followingUidsList.add(userPost);
);
return followingUidsList;




All I'm left with now is to communicate a new stream with userFollowing.uid.



How can I do it? thanks.










share|improve this question
























  • I think you can use nested StreamBuilders you can see example

    – cipli onat
    Mar 26 at 5:50











  • @ciplionat my stream function has an identifier which needs to be users id. This is the model from where i'm getting the ids.. they've been retrieved from the first stream List<UserFollowing> userInfoList = usersContentBloc.getFollowingsUidToList(docs); now do i need to do userInfoList[0].uid or is there another way to do it.

    – john haris
    Mar 26 at 17:38

















0















I'm trying to get the Ids of users i'm following from a firestore stream and then call another stream with the posts of my followings with the ids from previously.



I don't know if this is the right way to architect it and if so how to implement it with flutter.. I've been trying streamBuilder for the first call, but I don't know how to make the second stream call with a list of ids.



The function that I used to get the followings Ids



Stream<QuerySnapshot> followingUsersContent(String uid)
return _firestore.collection("following").document(uid).collection("userFollowing").snapshots();



and to get their posts:



Stream<DocumentSnapshot> myContentList(String userId) 
return _firestore.collection("posts").document(userId).collection("userPosts").document().snapshots();



This is how I retrieve the first list of Id's from the widget:



postWidget()
return Container(
child: StreamBuilder<QuerySnapshot>(
stream: usersContentProvider.followingUsersContent(profileId),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot)
if (!snapshot.hasData)
return Text("There's no data");


if (snapshot.hasData)

List<DocumentSnapshot> docs = snapshot.data.documents;

List<UserFollowing> userInfoList = usersContentProvider.getFollowingsUidToList(docs);

return testUserID(userInfoList);


,
),
);



Widget testUserID(List<UserFollowing> userInfoList)
return Container(
child: Expanded(
child: ListView.builder(
itemCount: userInfoList.length,
itemBuilder: (BuildContext context, i)

return Text(userInfoList[i].uid ?? "There's no data", style: TextStyle(color: Colors.red),);

),
),
);



So far so good everything is fine.



Now should I put another stream builder inside the listView.Builder() "I don't think it's a good idea".. because it is retrieving a list of uid with the (itemBuilder context, i). Or is there a better way to call the stream with all the uids I have.
Ps the uids are stored in the UserFollowing model:



class UserFollowing
final String _uid;


UserFollowing(this._uid);

String get uid => _uid;



and stored from here:



List getFollowingsUidToList(List<DocumentSnapshot> docList)
if (docList != null)
List<UserFollowing> followingUidsList = [];
docList.forEach((document)
String uid = document.data["uid"];

UserFollowing userPost = UserFollowing(uid);
followingUidsList.add(userPost);
);
return followingUidsList;




All I'm left with now is to communicate a new stream with userFollowing.uid.



How can I do it? thanks.










share|improve this question
























  • I think you can use nested StreamBuilders you can see example

    – cipli onat
    Mar 26 at 5:50











  • @ciplionat my stream function has an identifier which needs to be users id. This is the model from where i'm getting the ids.. they've been retrieved from the first stream List<UserFollowing> userInfoList = usersContentBloc.getFollowingsUidToList(docs); now do i need to do userInfoList[0].uid or is there another way to do it.

    – john haris
    Mar 26 at 17:38













0












0








0








I'm trying to get the Ids of users i'm following from a firestore stream and then call another stream with the posts of my followings with the ids from previously.



I don't know if this is the right way to architect it and if so how to implement it with flutter.. I've been trying streamBuilder for the first call, but I don't know how to make the second stream call with a list of ids.



The function that I used to get the followings Ids



Stream<QuerySnapshot> followingUsersContent(String uid)
return _firestore.collection("following").document(uid).collection("userFollowing").snapshots();



and to get their posts:



Stream<DocumentSnapshot> myContentList(String userId) 
return _firestore.collection("posts").document(userId).collection("userPosts").document().snapshots();



This is how I retrieve the first list of Id's from the widget:



postWidget()
return Container(
child: StreamBuilder<QuerySnapshot>(
stream: usersContentProvider.followingUsersContent(profileId),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot)
if (!snapshot.hasData)
return Text("There's no data");


if (snapshot.hasData)

List<DocumentSnapshot> docs = snapshot.data.documents;

List<UserFollowing> userInfoList = usersContentProvider.getFollowingsUidToList(docs);

return testUserID(userInfoList);


,
),
);



Widget testUserID(List<UserFollowing> userInfoList)
return Container(
child: Expanded(
child: ListView.builder(
itemCount: userInfoList.length,
itemBuilder: (BuildContext context, i)

return Text(userInfoList[i].uid ?? "There's no data", style: TextStyle(color: Colors.red),);

),
),
);



So far so good everything is fine.



Now should I put another stream builder inside the listView.Builder() "I don't think it's a good idea".. because it is retrieving a list of uid with the (itemBuilder context, i). Or is there a better way to call the stream with all the uids I have.
Ps the uids are stored in the UserFollowing model:



class UserFollowing
final String _uid;


UserFollowing(this._uid);

String get uid => _uid;



and stored from here:



List getFollowingsUidToList(List<DocumentSnapshot> docList)
if (docList != null)
List<UserFollowing> followingUidsList = [];
docList.forEach((document)
String uid = document.data["uid"];

UserFollowing userPost = UserFollowing(uid);
followingUidsList.add(userPost);
);
return followingUidsList;




All I'm left with now is to communicate a new stream with userFollowing.uid.



How can I do it? thanks.










share|improve this question
















I'm trying to get the Ids of users i'm following from a firestore stream and then call another stream with the posts of my followings with the ids from previously.



I don't know if this is the right way to architect it and if so how to implement it with flutter.. I've been trying streamBuilder for the first call, but I don't know how to make the second stream call with a list of ids.



The function that I used to get the followings Ids



Stream<QuerySnapshot> followingUsersContent(String uid)
return _firestore.collection("following").document(uid).collection("userFollowing").snapshots();



and to get their posts:



Stream<DocumentSnapshot> myContentList(String userId) 
return _firestore.collection("posts").document(userId).collection("userPosts").document().snapshots();



This is how I retrieve the first list of Id's from the widget:



postWidget()
return Container(
child: StreamBuilder<QuerySnapshot>(
stream: usersContentProvider.followingUsersContent(profileId),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot)
if (!snapshot.hasData)
return Text("There's no data");


if (snapshot.hasData)

List<DocumentSnapshot> docs = snapshot.data.documents;

List<UserFollowing> userInfoList = usersContentProvider.getFollowingsUidToList(docs);

return testUserID(userInfoList);


,
),
);



Widget testUserID(List<UserFollowing> userInfoList)
return Container(
child: Expanded(
child: ListView.builder(
itemCount: userInfoList.length,
itemBuilder: (BuildContext context, i)

return Text(userInfoList[i].uid ?? "There's no data", style: TextStyle(color: Colors.red),);

),
),
);



So far so good everything is fine.



Now should I put another stream builder inside the listView.Builder() "I don't think it's a good idea".. because it is retrieving a list of uid with the (itemBuilder context, i). Or is there a better way to call the stream with all the uids I have.
Ps the uids are stored in the UserFollowing model:



class UserFollowing
final String _uid;


UserFollowing(this._uid);

String get uid => _uid;



and stored from here:



List getFollowingsUidToList(List<DocumentSnapshot> docList)
if (docList != null)
List<UserFollowing> followingUidsList = [];
docList.forEach((document)
String uid = document.data["uid"];

UserFollowing userPost = UserFollowing(uid);
followingUidsList.add(userPost);
);
return followingUidsList;




All I'm left with now is to communicate a new stream with userFollowing.uid.



How can I do it? thanks.







firebase dart flutter google-cloud-firestore






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 10:33









KENdi

6,0372 gold badges10 silver badges22 bronze badges




6,0372 gold badges10 silver badges22 bronze badges










asked Mar 26 at 4:35









john harisjohn haris

111 silver badge2 bronze badges




111 silver badge2 bronze badges












  • I think you can use nested StreamBuilders you can see example

    – cipli onat
    Mar 26 at 5:50











  • @ciplionat my stream function has an identifier which needs to be users id. This is the model from where i'm getting the ids.. they've been retrieved from the first stream List<UserFollowing> userInfoList = usersContentBloc.getFollowingsUidToList(docs); now do i need to do userInfoList[0].uid or is there another way to do it.

    – john haris
    Mar 26 at 17:38

















  • I think you can use nested StreamBuilders you can see example

    – cipli onat
    Mar 26 at 5:50











  • @ciplionat my stream function has an identifier which needs to be users id. This is the model from where i'm getting the ids.. they've been retrieved from the first stream List<UserFollowing> userInfoList = usersContentBloc.getFollowingsUidToList(docs); now do i need to do userInfoList[0].uid or is there another way to do it.

    – john haris
    Mar 26 at 17:38
















I think you can use nested StreamBuilders you can see example

– cipli onat
Mar 26 at 5:50





I think you can use nested StreamBuilders you can see example

– cipli onat
Mar 26 at 5:50













@ciplionat my stream function has an identifier which needs to be users id. This is the model from where i'm getting the ids.. they've been retrieved from the first stream List<UserFollowing> userInfoList = usersContentBloc.getFollowingsUidToList(docs); now do i need to do userInfoList[0].uid or is there another way to do it.

– john haris
Mar 26 at 17:38





@ciplionat my stream function has an identifier which needs to be users id. This is the model from where i'm getting the ids.. they've been retrieved from the first stream List<UserFollowing> userInfoList = usersContentBloc.getFollowingsUidToList(docs); now do i need to do userInfoList[0].uid or is there another way to do it.

– john haris
Mar 26 at 17:38












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349914%2fhow-to-get-a-stream-value-and-then-call-another-stream-based-on-the-previous-val%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349914%2fhow-to-get-a-stream-value-and-then-call-another-stream-based-on-the-previous-val%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현