3

Using Flutter with GetX.

I have a GetX controller for items and I have a list of items.

When I use

final ItemController c = Get.find();

it uses the same controller for each item in the list and the values within every item get overwritten.

How can I get a unique controller for each item in the list? Is there a "Key" concept?

Simpler
  • 1,317
  • 2
  • 16
  • 31

1 Answers1

4

Despite your given information is insufficient in regards with what you want to achieve, the answer of your question is: Yes! There is a concept like "Key" in GetX. You can tag your controllers or dependencies when putting like:

Get.put(ItemController(), tag: "yourTag")

And when finding:

final taggedController = Get.find<ItemController>(tag:"yourTag");
S. M. JAHANGIR
  • 4,324
  • 1
  • 10
  • 30