What is the difference between calling the function without parentheses and with parentheses on onPressed or Ontap?
I just know that void function can\'t be called with
Here is the difference:
onPressed: _incrementCounter is a reference to an existing function is passed.
This only works if the parameters of the callback expected by onPressed and _incrementCounter are compatible.
onPressed: _incrementCounter() _incrementCounter() is executed and the returned result is passed to onPressed. This is a common mistake when done unintentionally when actually the intention was to pass a reference to _incrementCounter instead of calling it.