Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 399
Simpler Avatar asked Oct 21 '25 16:10

Simpler


1 Answers

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");
like image 163
S. M. JAHANGIR Avatar answered Oct 23 '25 08:10

S. M. JAHANGIR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!