Answers for "flutter multi icon button"

0

flutter multi icon button

List<Icon> icons = [
  ESGIcons.star,
  ESGIcons.crown,
];
int buttonOnPressed = -1;
ListView.builder(
    scrollDirection : Axis.horizontal,
    shrinkWrap: true,
    itemCount: icons.length,
    itemBuilder: (BuildContext context, int index) {
      return IconButton(
        iconSize: 25,
        onPressed: () {
          setState(() {
            buttonOnPressed = index;
          });
        },
        icon: Icon(icons[index]),
        color: (buttonOnPressed == index)
            ? AppTheme.esgEasyYellow
            : AppTheme.esgDarkBlue,
      );
    });
Posted by: Guest on October-23-2021

Browse Popular Code Answers by Language