You have two options to implement switching to the Recipes tab:
Standard callback: Pass a callback from the parent widget all the way down the widget tree to a descendant widget. When ready, it fires the callback at each level up the tree and calls setState() to rebuild the Home widget’s subtree.
Hi @eryawanir ,
Passing a callback might be best used when passing data from a child widget to a parent widget. Using callbacks in multiple levels of a widget tree might be a little bit tedious. Maybe @jomoka can help us on that.
But i’ll give you a simple example below:
Let’s say we have two widgets,
a child widget that looks like the one below:
On this widget, we have defined a callback final Function(int) onCountChanged;
There is a button, when a user clicks the button, onCounntChanged is called:
a parent widget that looks like the one below:
and a child widget that looks like the one below:
When a the elevated button is clicked, the change value is passed from the Count child widget to the CounterPage parent widget. Then, the addition between the val and count is performed and count is updated.