how to make a list observable with getx in flutter

2,499

Solution 1

You can specify the type of the list easily like this

var products = <Product>[].obs;

Solution 2

Try this

RxList<Product> product = (List<Product>.of([])).obs;
Share:
2,499
Atmane AYOUB
Author by

Atmane AYOUB

Updated on December 31, 2022

Comments

  • Atmane AYOUB
    Atmane AYOUB over 1 year

    I was watching tutorials on using Getx with APIs. after setting a controller for fetching data. we declared a list variable and made it observable(obs). but the list format was deprecated. can you help me how can i do it now.

    var products = List<Product>().obs;
    
  • dhruvanbhalara
    dhruvanbhalara over 2 years
    @AtmaneAYOUB I have updated my answer please check and let me know if it's working or not