I am building an App with Flutter using Firebase as a "backend". I have to display quite long and complex to build lists and was wondering if there was a more performance-based approach than my current approach:
This is what I do at the moment:
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection("collection" ).limit(200).snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Center(
child: CircularProgressIndicator());
} else {
return _buildComplexeList(snapshot);
}
},
);
This leads to following problem: Every time something gets updated in the list all widgets are rebuilt within the list. Also, I wanted to use an AnimatedList and it is quite hard to find out whether an item was added or not and if yes, where it was added.
I was wondering if you could use
.snapshots().listen((event) { }
which returns a StreamSubscription instead of a stream, but to be honest I have no idea how. This could help to only build the changed widgets.
It would be great to know if some of you have some other and better solution approaches. Thanks in advance!
Paul