0

I have a long list of items (objects) and each item has a getx controller. Get.put(ItemController(itemModel), tag: itemModel.value.id.toString()) is set in the ListView.builder() when the item tile is created, but it seems that the controller only actually gets created when the tile is displayed and only the first 10 or so are displayed initially.

I then need to update the values for all (many) of the items.

When I attempt to update the values in the item controllers, it can't "find" the controllers (because they have not yet been created).

Is it ok to use Get.put() again for the same item? Or is there a better way to access these item controllers?

Simpler
  • 1,317
  • 2
  • 16
  • 31

1 Answers1

0

You need to create a method which loops through your list item and puts your dependencies for each item. And you need to call that method on the build method, before ListView.builder.

  • GetX only creates the dependencies when they are needed. Like, if you just 'Get.put(Something())', it will not necessarily be called at the moment of calling Get.put. Usually the dependencies gets created when that dependency is being used for the first time. So GetX will create Something when something.someOtherThing is called.
S. M. JAHANGIR
  • 4,324
  • 1
  • 10
  • 30