title: How to get the items from list according to id in flutter?
body: <p><strong>Requirement:</strong></p>
  <p>I created a list of days using <code>CheckboxlistTile</code>, and i want when i check any checkbox a <code>button</code> will display, and onclick on button a <code>dialogue</code> will display where user can add time in textfield, and then on click on submit button of dialogue that <code>textfield</code> time input will convert into a tag and will display below the <code>checkbox</code>.</p>
  <p>here my screen look like before check the checkbox</p>
  <p><a href="https://i.stack.imgur.com/LmfsP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LmfsP.png" alt="enter image description here" /></a></p>
  <p>initially i set Monday checkbox checked.</p>
  <p>so when i click on add button (which in at the right of checkbox), this dialogue will display</p>
  <p><a href="https://i.stack.imgur.com/uJGGT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uJGGT.png" alt="enter image description here" /></a></p>
  <p>and when i enter the values and after clicking on submit button, tag will look like this</p>
  <p><a href="https://i.stack.imgur.com/c4cMS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c4cMS.png" alt="enter image description here" /></a></p>
  <p><strong>Problem:</strong></p>
  <p>Problem is, when i check the tuesday or any other checkbox this tag is displaying in its list, wherease i have not selected time for tuesday or any checkbox, i guess the problem is in list which i'm passing to create tags <code>_timingTagListForToken</code></p>
  <p><a href="https://i.stack.imgur.com/ZurRS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZurRS.png" alt="enter image description here" /></a></p>
  <p>here is the code:</p>
  <p><strong>Days list class</strong></p>
  <pre><code>class CheckBoxListTileModelForToken {
    int id;
    String title;
    bool isCheck;
  
    CheckBoxListTileModelForToken({required this.id,required this.title, required this.isCheck});
  
    static List&lt;CheckBoxListTileModelForToken&gt; getUsers() {
      return &lt;CheckBoxListTileModelForToken&gt;[
      CheckBoxListTileModelForToken(id:1,title: &quot;Monday&quot;, isCheck: true,),
      CheckBoxListTileModelForToken(id:2,title: &quot;Tuesday&quot;, isCheck: false),
      CheckBoxListTileModelForToken(id:3,title: &quot;Wednesday&quot;, isCheck: false),
      CheckBoxListTileModelForToken(id:4,title: &quot;Thursday&quot;, isCheck: false),
      CheckBoxListTileModelForToken(id:5,title: &quot;Friday&quot;, isCheck: false),
      CheckBoxListTileModelForToken(id:6,title: &quot;Saturday&quot;, isCheck: false),
      CheckBoxListTileModelForToken(id:7,title: &quot;Sunday&quot;, isCheck: false),
      ];
    }
  }
  </code></pre>
  <p><strong>Code where i'm display the Checkboxes</strong></p>
  <pre><code>customExpansionTile(context, &quot;Token Distribution Time&quot;, 
            true,
              Icon(Icons.timer, color: HexColor(&quot;#5344ed&quot;)), 
              &lt;Widget&gt;[
              Container(
                  child: Row(
                children: [
                  Expanded(
                      child: SizedBox(
                          height: MediaQuery.of(context).size.height * 0.45,
                          child: ListTile(
                            title: ListView.builder(
                            itemCount: checkBoxListTileModelForToken.length,
                            itemBuilder: (BuildContext context, int index) {
                            return new Card(
                              child: new Container(
                                padding: new EdgeInsets.all(10.0),
                                child: Column(
                                  children: &lt;Widget&gt;[
                                    new CheckboxListTile(
                                        controlAffinity:ListTileControlAffinity.leading,
                                        activeColor: HexColor(&quot;#5344ed&quot;),
                                        dense: true,
                                        title: new Text(
                                          checkBoxListTileModelForToken[index].title,
                                          style: TextStyle(
                                              fontSize: 14,
                                              fontWeight: FontWeight.w600,
                                              letterSpacing: 0.5),
                                        ),
                                        value: checkBoxListTileModelForToken[index].isCheck? true:false,
                                        secondary:  Container(
                                        alignment:Alignment.centerRight,
                                        height: MediaQuery.of(context).size.height*0.9,
                                        width: MediaQuery.of(context).size.width *0.2,
                                        child:checkBoxListTileModelForToken[index].isCheck ==true?
                                            IconButton(
                                              tooltip:&quot;Pick Time&quot;,
                                              onPressed: () {
                                                _tokenTimeDialogue(
                                                    checkBoxListTileModelForToken[index].id);
                                              },
                                              icon: Icon(Icons.add,color: HexColor(&quot;#5344ed&quot;),)
                                            )
                                                : null),
                                      onChanged: (bool? val) {
                                   itemChangeforToken(val!, index);
                                      }),
                                      SizedBox10(),
                                      Wrap(
                                        direction:Axis.horizontal,
                                        children:[
                                          Container(
                                        child:checkBoxListTileModelForToken[index].isCheck? Tags(
                                          itemCount:_timingTagListForToken.length,
                                          itemBuilder: (int index){          
                                          return  ItemTags(
                                                key: Key(index.toString()),
                                                activeColor:HexColor(&quot;#5344ed&quot;),
                                                index: index, 
                                                title:_timingTagListForToken[index],
                                                textStyle: TextStyle( fontSize: 14, ),
                                                combine: ItemTagsCombine.withTextBefore,
                                                
                                                removeButton: ItemTagsRemoveButton(
                                                  backgroundColor:HexColor(&quot;#5344ed&quot;),
                                                  onRemoved: (){  
                                                      setState(() {
                                                          _timingTagListForToken.removeAt(index);
                                                      });
                                                      return true;
                                                  },
                                                ),
                                                onPressed: (item) =&gt; print(item),
                                                onLongPressed: (item) =&gt; print(item),
                                          );
                                        },):Padding(
                                          padding: const EdgeInsets.only(left: 70),
                                          child:
                                              Row(crossAxisAlignment: CrossAxisAlignment.center, children: []))
                                                                  ),
                                        ])]),
                            ),
                          );
                        }),
                    
                        ))),
  
  
  
   itemChangeforToken(bool val, int index) {
    setState(() {
      //id=checkBoxListTileModelForToken[index].id;
        //print(&quot;id onchange &quot;+ id.toString());
      checkBoxListTileModelForToken[index].isCheck = val;
  
     
      
    });
    
  }
  
  
  </code></pre>
  <p><strong>Dialogue code</strong></p>
  <pre><code>
  _tokenTimeDialogue(dynamic id) {
      AlertDialog alert = AlertDialog(
          scrollable: true,
          insetPadding: EdgeInsets.symmetric(vertical: 50),
          title: Text(&quot;Add timing of the day&quot;,
            style: TextStyle(fontWeight: FontWeight.bold, color: HexColor(&quot;#5344ed&quot;))),
          content: Container(
            child: SingleChildScrollView(
            scrollDirection: Axis.vertical,
            child: Column(children: &lt;Widget&gt;[
              textfieldforTimeDialogue(
                context,
                () async {
                      TimeOfDay? pickedTime = await showTimePicker(
                        initialTime: TimeOfDay.now(),
                        context: context,
                        builder:(context, child) {
                              return Theme(
                                data: Theme.of(context).copyWith(
                                  colorScheme: ColorScheme.light(
                                    primary: HexColor(
                                        &quot;#6610f2&quot;), // header background color
                                    onPrimary: Colors.black, // header text color
                                    onSurface: Colors.black, // body text color
                                  ),
                                  textButtonTheme: TextButtonThemeData(
                                    style: TextButton.styleFrom(
                                      primary: HexColor(
                                          &quot;#6610f2&quot;), // button text color
                                    ),
                                  ),
                                ),
                                child: child!,
                              );
                            },
                      );
                      if (pickedTime != null) {
                        setState(() {
                          fromTimeForToken.text = pickedTime.format(context);
                        });
                      } else {
                        print(&quot;Time is not selected&quot;);
                      }
                    },
                    Icons.timer_off,
                    fromTimeForToken,
                    &quot;From&quot;,
                    &quot;From&quot;,
              ),
              
              SizedBox20(),
              textfieldforTimeDialogue(
                context,
                () async {
                  FocusScope.of(context).unfocus();
                      TimeOfDay? pickedTime = await showTimePicker(
                        initialTime: TimeOfDay.now(),
                        context: context,
                         builder:(context, child) {
                              return Theme(
                                data: Theme.of(context).copyWith(
                                  colorScheme: ColorScheme.light(
                                    primary: HexColor(
                                        &quot;#6610f2&quot;), // header background color
                                    onPrimary: Colors.black, // header text color
                                    onSurface: Colors.black, // body text color
                                  ),
                                  textButtonTheme: TextButtonThemeData(
                                    style: TextButton.styleFrom(
                                      primary: HexColor(
                                          &quot;#6610f2&quot;), // button text color
                                    ),
                                  ),
                                ),
                                child: child!,
                              );
                            },
                      );
                      if (pickedTime != null) {
                        setState(() {
                          toTimeForToken.text = pickedTime.format(context);
                        });
                      } else {
                        print(&quot;Time is not selected&quot;);
                      }
                    },
                    Icons.timer_off,
                    toTimeForToken,
                    &quot;To&quot;,
                    &quot;To&quot;,
              ),
            ]),
          )),
          actions: [
            TextButton(
              
              onPressed: () {
              setState(() {
              fromTimeForToken.text=&quot;&quot;;
              toTimeForToken.text=&quot;&quot;;
              });
                Navigator.pop(context);
              },
              child: Text(
                &quot;Submit&quot;,
                style: TextStyle(
                    fontWeight: FontWeight.bold,
                    color: HexColor(&quot;#5344ed&quot;),
                    fontSize: 20),
              ),
            )
          ]);
      showDialog(
        context: context,
        builder: (BuildContext context) {
          return alert;
        },
      );
    }
  
  
  </code></pre>
  <p>please help where i'm doing wrong, how i can do this?</p>