how to pass a function when class is created flutter code example
Example 1: flutter use valuechanged function in function
class 1{
Function(String value) onChanged,
TextField(
onChanged: (value){
onChanged(value);
state.didChange(value);
},
)
}
class 2{
new 1({
...
onChanged: (value) {
restaurant.name = value;
},
...
});
}
Example 2: dart callback function with parameter
class Obj {
String Function(String, int, etc...) callbackName;
Obj(this.callbackName);
}
main() {
var myObj = Obj((String p1, int p2, etc...) {
return "$p1$p2";
});
}