I have a bool fetchNew
. It's initialized as false and I have a function refresh() that sets it to true. How do I set it to false right after setState preventing the rerender?
class _DashboardState extends State<Dashboard> {
bool fetchNew = false;
@override
void initState() {
super.initState();
}
refresh() {
setState(() {
fetchNew = true;
});
}
@override
Widget build(BuildContext context) {
return Container();
}
}
I thought initState() would set it to false again after rerender but the way I understand initState is that it will only fire once to inject the Widget into the widget tree.