Home > front end >  Parameter type issue of FaIcon in Flutter
Parameter type issue of FaIcon in Flutter

Time:11-17

     final FaIcon? icon;
      const ButtonWidget({
        super.key,
        this.icon,
      });

      Widget build(BuildContext context) {
    return Row(
            children: [
              FaIcon(icon) // "The argument type 'FaIcon?' can't be assigned to the parameter type 'IconData?',),
        ),
      ],
    );
  }

I defined the value named icon as FaIcon. But to me; The argument type 'FaIcon?' can't be assigned to the parameter type 'IconData? Gives a fault.

CodePudding user response:

"FaIcon" take as the first unnamed parameter an "IconData?" not another instance of "FaIcon" (see https://github.com/fluttercommunity/font_awesome_flutter/blob/master/lib/src/fa_icon.dart).

You should do something like that:

final IconData? icon;

or

FaIcon(FontAwesomeIcons.THE_ICON_YOU_WANT), 

CodePudding user response:

Changed final FaIcon? icon; to final FaIcon icon;

after that change this.icon =FaIcon(FontAwesomeIcons.home)//default icon

Remove FaIcon(icon) and add icon in the children

  • Related