Search code examples
androidflutterdartflutter-android

how add a value to the list that in singleton class? (flutter)


this is my code enter image description here

how I can add some string to my items list?


Solution

  • because List<String>.filled(1, "") constructor has a third parameter growable and defaults to false. so this line creates a fixed list by default and you cannot add new values to it, you should use this instead

    List<String>.filled(1, "", growable: true);
    

    this will make the list growable and now you can add new entries.