Search code examples
jsonflutterdio

I have an api which provides some text data, but the text doesnt work in ListStyle


Json object works in text but not in ListStyle!!


Solution

  • I think the problem you are having is because you have made the ListTile as a const which would require all the variables inside it to have a fixed value which is available while the app is building while in case of json the app is built first then you inquire data from json. So try removing the const before listTile and your code will work.

    A detailed definition of const in dart can be found here