How to update text based on ListWheelScrollView

49 views Asked by At

I am trying to cycle through an array of texts based on ListWheelScrollView using onSelectedItemChanged, but the text does not update, however the variable change does appear in the console

I am extending StatefulWidget too

Here is my ListWheelScrollView:

ListWheelScrollView(
                    onSelectedItemChanged: (i) {
                      setState(() {
                        prompt = promptList[i];
                        devtools.log(prompt);
                      });
                    },
...

and my Text widget looks like this:

Text("$prompt",
                    key: const Key("textKey"),
                    style: const TextStyle(
                        color: Color.fromARGB(255, 255, 255, 250))),
              ),
1

There are 1 answers

0
zinger44 On

I defined my variable prompt inside my build widget instead of the class itself, I'll leave this in case someone else makes the same mistake