Closed ejabu closed 6 years ago
Oh, definitely okay to use List.
UnmodifiableListView
is there for safety. It's immutable, so consumers of the Cart
class cannot change the items in the class via the Cart.items
getter. They have to go through Cart.add()
and Cart.remove()
(which make sure to do the right thing).
So, this is just a bit of encapsulation. For a smaller project and for learning purposes, it's okay to use a List
.
I'm closing this but feel free to reopen if it's not clear or helpful.
https://github.com/filiph/state_experiments/blob/19c321bbc62ac10855751124e3ea9701e583d6ea/shared/lib/common/models/cart.dart#L36
I prefer to try bloc_start architecture.
Is it okay to change this to normal ListView ?
What is the purpose of this actually ?