Let's say I have a widget called the TheGroupListPage. This widget has a StreamBuilder, which will listen to a Stream<List<Group>>
and rebuild a ListView() of groups accordingly. Each item in the list is clickable and sends you to a another page called TheGroupPage(GroupModel group)
.
So now I am on TheGroupPage(GroupModel group)
and I only care about a single group. But my problem is that the StreamBuilder will continue to listen to a Stream<List<Group>>
. So how do I stop this?
The only way I can think off is to make TheGroupList page a statefull widget and give it a stream controller. Then somehow close that controller and cancel the subscription once I arrive at TheGroupPage().
But there must be a more elegant way right?
Just to be clear. This is not about unwanted building as talked about here
How to deal with unwanted widget build?
It's about minimizing data usage.