1

I was trying to create an app using the flutter desktop implementation that would read the path to an image from a JSON file and display the image, and then when an Inkwell is hovered, it would change the path to another image. The following was the declaration of variables:

characterName = 'Elise';
var skill_1_icon_path =
            characterData[characterName]['ability 1']['icon path'];

I was changing the characterName variable to switch to other image paths. The following widget was being used:

Inkwell(
        child: Image(
                 image : AssetImage(
                    skill_1_icon_path),
                 ),
                onHover: (value){setState(){characterName = "Jhon";}}
               ),
           )

However, the image does not change despite changing the path. I have tried printing skill_1_icon_path in both before hovering and after, the path changes to it's correct value, but the image itself doesn't.

RikSantra
  • 81
  • 1
  • 10

1 Answers1

0

In your onHover, use setState to also change skill_1_icon_path to the desired new image path.

Huthaifa Muayyad
  • 11,321
  • 3
  • 17
  • 49