DEV Community

Peter Haddad
Peter Haddad

Posted on

Answer: What is the difference between calling the function without parentheses and with parentheses

_incrementCounter inside onPressed is a function reference, which basically means it is not executed immediately, it is executed after the user clicks on the specific widget.(callback)

_incrementCounter() is a function call and it is executed immediately.

Therefore, inside onPressed you can either pass a function reference or an anonymous function…

Top comments (0)