1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Getx , Flutter how to update state of a variable in a listview builder everytime...

Discussão em 'Mobile' iniciado por Stack, Outubro 10, 2024 às 09:23.

  1. Stack

    Stack Membro Participativo

    so i have to create a wishlist , and i am getting data from api . If the api returns outofstock = true , i will need to hide add to cart button and if the api returns in stock i will need to display the button . The problem is in getx we need obs variable to change state , and if i create an obs variable and update its value everytime its still taking the initial value.

    i tried creating an obs variable to collect response from api and save it to obs variable then use that variable to check if its in stock then show the button else not , but the value of obs variable is false everytime help ListView.builder( physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: controller.wishlistData.length, itemBuilder: (BuildContext context, int index) { final data =controller.wishlistData[index]; controller.outOfStockFlag.value = data.variantMeta!.bOutOfStockFlag!; the value of controller.outOfStockFlag is intially set to true then for next build it remains staticall true, where as in response i am getting true as well as false

    Continue reading...

Compartilhe esta Página