Flutter’s invisibility cloak — SetState()

Refreshing on the Counter App

Counter Application Home Page
  1. There’s one stateful field called _counter.
  2. We also have a Text widget that displays the value of _counter.
  3. Every time we want to update _counter, we also have to wrap it in an anonymous function and pass it to setState(). Otherwise, the framework doesn’t know what was updated.
Demo for counter app

Let's take a peek behind the invisibility cloak

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store