Do you think it's okay to have a list of StateNotifiers inside the State of other StateNotifier? For example like this:
class ListOfItems extends StateNotifier<ListState> {
void doSomethingWithList() {
// update state of list -> rebuild ListWidget
}
void doSomethingWithItem(int itemIndex) {
final item = state.items[itemIndex];
item.doSomethingWithItem();
}
}
class ListState {
final List<Item> items;
// some other properties
ListState(this.items);
}
class Item extends StateNotifier<ItemState> {
// can be called directly from the ItemWidget (on a button press) or from the ListOfItems
void doSomethingWithItem() {
// update state of item -> rebuild ItemWidget
}
}
class ItemState {
// some properties
}
I tried it and it seems to me that it works well. Could there be pitfalls?