Reputation: 327
I wanna check if the Icon
doesn't return null and if it returns null then show the SvgPic
, or else show the Icon
.
Errors:
.
final SvgPicture? svgPic; final Icon? icon;
child: Container(widget.icon == null
? widget.svgPic
: Icon(widget.icon.icon,
color: widget.iconColour)),
),
Upvotes: 1
Views: 46
Reputation: 107121
You didn't add any parameter label in that container
You are trying to access the icon property of a nullable, so you need to use ? or !.
Instead of:
Container(widget.icon == null ? widget.svgPic
: Icon(widget.icon.icon, color: widget.iconColour),
),
Use:
Container(child: widget.icon == null ? widget.svgPic
: Icon(widget.icon!.icon, color: widget.iconColour)
),
Upvotes: 1