I have a function that I use to build an icon widget:
buildIcon(IconData icon, Color color, VoidCallback onTap, {double? size}) {
return InkWell(
onTap: onTap,
child: Icon(
// set size only if argument size != null
icon,
color: color,
),
);
}
As you can see this function has nullable argument size
. And I need this parameter to be set only if it is not equal to null. If I add a check for null, then I will have to add a default value for the size
parameter of the icon widget.
Is it possible to avoid setting the size
parameter of Icon
widget if the function argument is null ? Please, help me.
You can use like this:
}
or:
}