Home > OS >  flutter change the color of selected items from the map list
flutter change the color of selected items from the map list

Time:01-19

im trying to change the color of the selected items from a map list. the below code is what tried but this only change the color of the last item selected, and what i want to achieve is to change all the selected items colors. thanks.

  String selectedSport = '';

Wrap(
       
        children: List1.entries.map<Widget>((entry) {
          return FittedBox(
                fit: BoxFit.fill,
                child: Container(
                    margin: const EdgeInsets.all(8.0),
                    padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7),
                    decoration: BoxDecoration(
                      color: selectedSport == entry.key? AppColor.blueColor.withOpacity(0.3): Colors.white ,
                        borderRadius: BorderRadius.all(Radius.circular(20)),
                        border: Border.all(color: AppColor.blueColor)),
                    child: Center(
                        child: GestureDetector(
                            onTap: () {

                              setState(() {
                                selectedSport = entry.key;  
                              }); 
                            },
                            child: Text(entry.key, style: GoogleFonts.inter(
                            fontSize: 14,
                            fontWeight: FontWeight.w600,
                            color: AppColor.blueColor),
                             ),
                             ),
                             ),
                             ),
              );
        
        }).toList(),
      ),

 Map<String, bool> List1 = {
    'Bubble Football ⚽': false,
    'Futsal            
  •  Tags:  
  • Related