I cannot use function that has optional parameter in child widget(name is FixUI).This is original function declared in parent widgetThis is the line error occured(red line: Underfined~)
I want to make fixContact function arguments : fixContact, index, contact but in optional. How can I do it? Does flutter has this feature? Are there any other ways? Or did I missunderstood anything?
4
Answers
I found a stupid mistake... I confused constructor and function parameter.
Make this changes :
To make widget arguments optional, you either have to make them nullable or provide a default value. Also, currently, you do not specify Function arguments, but widget arguments. Function arguments in this case are optional if they are named – inside curly braces.
Here is an example how to provide more information to your function.
typedef MyCallback = void Function(int optionalParam);
3.In the child widget, define a callback property of the same type as the function signature.