From this answer:
The build method is designed in such a way that it should be pure/without side effects.
and
This means that the build method should not trigger an http call or modify any state.
But this contradicts with firestore plugin usage example(condensed for briefness):
class BookList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return StreamBuilder<QuerySnapshot>(
stream: Firestore.instance.collection('books').snapshots(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
// do something with books
},
);
}
}
Anytime when build
method called, builder
function from StreamBuilder
called as well.
What I tried:
...
stream: Firestore.instance.collection('books').snapshots().distinct(),
...
Neither advice from previously mentioned answer works for this case.