So I have created a flutter page which has a bunch of inputs in it. I thought this is a mess, lets refactor it and created a new stateful widget for each input.
This is great except the data needs to be in the parent widget and I am having a hard time understanding how to pass the data back from the new child widgets to the parent.
I've found some hacky way where you pass in a function and whenever there is a change you pass the data to the parent through that function.. Works but now theres multiple variables, one in the child and one in the parent.
I've read about the bloc pattern and I'm not sure whether this is what i need. I just want a singleton style object that the main widget and its children can both read and the children update when there is new input.
I would be really grateful if someone could explain whether the bloc pattern would help me with this or if there is another design pattern that will help me with this.
Thank you
Aucun commentaire:
Enregistrer un commentaire