Is it ok to use a ScrollController
for a ListView
within a StatelessWidget
. If so, how can the controller be disposed?
Asked
Active
Viewed 2,714 times
4

King Elisha
- 97
- 3
- 10
1 Answers
4
If you are using a ScrollController
, I think that you probably has a State (to change or maintain) in your widget.
In that case you need to go for a StatefulWidget
.
I would just change to a StatefulWidget
and use the dispose()
method to clean memory.
But first of all, think if you controller has a purpose to exist in the first place. Maybe in your case makes sense.
Check this answer too --> Do stateless widgets dispose on their own?

encubos
- 2,915
- 10
- 19