Home > OS >  Is it possible to extract the value of a ValueKey in flutter?
Is it possible to extract the value of a ValueKey in flutter?

Time:05-24

I have a Column containing a series of containers, each of which has assigned a key of ValueKey(integer). The integer changes depending on a preassigned ID# for each item int he column

Now I need to know which of those containers is being viewed, so I can get a hold of the key for the container on the screen. However, when I try to debugPrint(mykey.key.toString()); I get a result of [<28935522>], meaning my integer that I assigned to the ValueKey is now surrounded by [<.

I could try to regex the integer from [<28935522>], but it seems silly to do that extra work, is there a way to directly extract the ValueKey value?

CodePudding user response:

Just use the value property as shown in the documentation. Documentation for ValueKey.value

mykey.key.value;
  • Related