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
void _incrementCounter() {
setState(() {
_counter++;
});
}
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
* As I see that in your code the return type is void for the function. in flutter if the return type is void and the function is defined in the same class, where the defined function is being called in the widget then we don't use parentheses. in a flutter, we simply call the function with using parentheses ...... which ultimately act as a pointer which will point towards function with return type void and defined in the same class in which function is called in widget *