PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 15, 2022

[FIXED] how to get the variable from my list in flutter

 August 15, 2022     flutter, output     No comments   

Issue

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.blue.withOpacity(0.5) : Colors.transparent,
                   //select and import to a category
                      child: ListTile(
                        //to remove
                        onTap: (){
                        if(_selectedItems.contains(HomePage.vocabularyList[index])){
                        setState(() {
                        _selectedItems.removeWhere((val) => val == HomePage.vocabularyList[index]);
                        });}},
                        //to add
                        onLongPress: (){
                         //print(HomePage.vocabularyList[index].CategoryId);
                        if(! _selectedItems.contains(HomePage.vocabularyList[index])){
                        setState(() {
                        _selectedItems.add(HomePage.vocabularyList[index]);
                        print(HomePage.vocabularyList[index]);
                        });}
                        },
                        title: _showWords(index),
              ),);

and output is:

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

Solution

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

print(Homepage.vocabularyList.elementAt(index).word);

Where word is String property of your Vocabulary class



Answered By - BLKKKBVSIK
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing