GetX: Controller for each item in a list


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?


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");

Answered By – S. M. JAHANGIR

Answer Checked By – Jay B. (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.