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

Issue

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.

Answered By – Michael Soliman

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *