In shorter word, my question is how to call child's initState()
again on parent's setState()
.
I need to reuse a widget class for multiple instances. I need the widgets to appear in turn like below where I can use setState()
to switch between them.
bool showthefirstone = true;
@override
Widget build(BuildContext context) {
...
TheWidget it = showthefirstone ? TheWidget(...) : TheWidget(..);
...
}
The later one's initState()
is not called. No problem showing them both together along at the same time. The issue only occurs upon setState()
.
For those who don't understand, this trigger the change
setState((){showthefirstone = !showthefirstone})