Populate And Emit StateFlow List
I want to use StateFlow. But for now, I don't find any lecture which could help me. I'm facing an issue : To start, I have a singleton which hold a list of String, I want something
Solution 1:
If you don't want to take temporary variable in-order to add new item to mutable list you can use plus (+) operator function. By doing so returns you new list (immutable) with added value that you can use further.
So the pseudo-code becomes something like this: val newList = oldMutableList + newItem
Similarly you can remove item from list like val newList = oldMutableList - itemToRemove
Read more about operator function on kotlin collection here!
Post a Comment for "Populate And Emit StateFlow List"