I know the syntax for calling a function after onPressed
and onTap
for a widget. There are two options We can use either the () => functio
If I understand your question correctly, you are asking about the bolded one () => function().
With that assumption I am trying to answer.
onTap, onPressed are the taking function
as arguments. Possible values can be
func callbackFunction() {
// what ever we want to do onTap
}
1. onTap: callbackFunction
2. onTap: () => callbackFunction() // onTap: callbackFunction() it will invoke the method while building itself.
// So we are making it lazy by wrapping in another anonymous function.
3. onTap: () { callbackFunction(); }
4. onTap: () => print("tapped") // anonymous one line function
5. onTap: () { print("tapped");
// what ever we want to do onTap
print("tapped");
} // anonymous multiline function