how to get the variable from my list in flutter


when i want to select from my list i don’t get the variable just this msg : Instance of Vocabulary.

color: (_selectedItems.contains(HomePage.vocabularyList[index])) ? : Colors.transparent,
                   //select and import to a category
                      child: ListTile(
                        //to remove
                        onTap: (){
                        setState(() {
                        _selectedItems.removeWhere((val) => val == HomePage.vocabularyList[index]);
                        //to add
                        onLongPress: (){
                        if(! _selectedItems.contains(HomePage.vocabularyList[index])){
                        setState(() {
                        title: _showWords(index),

and output is:

I/flutter (  338): Instance of 'Vocabulary'


It’s because your Vocabulary class doesn’t have a .toString() method.
You can try to display one of the properties of your class by using


Where word is String property of your Vocabulary class

Answered By – BLKKKBVSIK

Answer Checked By – Timothy Miller (FlutterFixes Admin)

Leave a Reply

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