This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I have a StreamBuilder that is for a firestore.
I have a button in a different page that is saving item prices into firestore. My StreamBuilder is for the total price of these items.
return Scaffold(
appBar: PreferredSize(
child: AppBar(
elevation: 0,
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
title: Center(child: Text('Main page')),
),
preferredSize: Size.fromHeight(30),
),
body: StreamBuilder(
stream: FirestoreAPI.getTotalUnpaid(currentUser),
builder: (BuildContext context, AsyncSnapshot snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.waiting:
return Center(
child: CircularProgressIndicator(),
);
default:
if (snapshot.hasError)
return Center(child: Text(snapshot.error.toString()));
else {
return Center(
child: Text(
snapshot.data['total'].toString(),
style: style,
),
);
}
}
},
),
);
The StreamBuilder should keep showing the value of the 'total' field every time it changes.
However, it only updates it after I hot reload the app. Why?
Should I be calling setState somewhere?
Also, can this be resolved by didUpdateWidget?
I have a somewhat similar problem elsewhere where the streambuilder does not update the first time only. But works fine after that.
Subreddit
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/flutterhelp...