I try to create some custom widget with some parameter in the constructor. This widget has some optional and required parameter. how can make Function
type paramete
Optional parameters can be either positional or named, but not both.
Named parameters are optional by default so you don't have to assign the default value.
const TextInputWithIcon(
{Key key,
@required this.iconPath,
this.placeHolder = "",
this.onFocusChange
})
: super(key: key);
and when calling the onFocusChange
perform a null check:
if(this.onFocusChange != null) {
this.onFocusChange(boolValue)
}
Have a look at Optional Parameters to understand better.
Edit: Thank you Jonah Williams to clarification.