Why Flutter defines that we should call:
setState(() { _counter++});
instead of:
_counter++;
setState(() {});
As far as I can see in setState()
code, it doesn't use anything that's passed as a parameter anyway.
Why Flutter defines that we should call:
setState(() { _counter++});
instead of:
_counter++;
setState(() {});
As far as I can see in setState()
code, it doesn't use anything that's passed as a parameter anyway.
The end result in release mode is the same.
But in debug you get an assert for free that checks that the callback inside setState()
does not return a Future
and it returns immediately.
But if you are sure the callback is synchronous, the result in debug is the same.