title: How can i enable/disable the DropDownButton according to the condition in Flutter?
body: <p>I am new in flutter and i am making leave application in that I have create two DropdownButton. In that one DropdownButton for <strong>From Date Half Leave:</strong> and Second one for <strong>To Date Half Leave</strong>. I am showing Same Item list in both DropdownButton.
  Problem is that when i select same item from the <strong>From Date Half Leave</strong> then it should <strong>do not hide</strong> the same options in second DropdownButton it means in the <strong>To Date Half Leave</strong> .</p>
  <p>For example,i want to do that if <strong>From date</strong> and <strong>To date</strong>  Are same then its show option in both dropdownbutton but when user Select the one item from <strong>From Date Half Leave</strong> then it hide the item option in <strong>To Date Half Leave</strong>. and if <strong>From date</strong> and <strong>To date</strong> are different then it show opposite option in <strong>From Date Half Leave</strong> and <strong>To Date Half Leave</strong> like if <strong>From Date Half Leave</strong> select Morning then in <strong>To Date Half Leave</strong> i does not show morning option its show only Afternoon option if the <strong>From Date Half Leave</strong> and <strong>To Date Half Leave</strong> are different then only. <strong>I can't able to do this so help me please..</strong></p>
  <p>My Code Below: i just try to make disable the items of <strong>To Date Half Leave</strong> when the <strong>From Date</strong> and <strong>To Date</strong> are same the when user select <strong>From Date Half Leave</strong> dropdownbutton item the its disable the  items in <strong>To Date Half Leave</strong> .</p>
  <p>var _days = ['Morning', 'Afternoon',];</p>
  <pre><code>    Padding(
                     padding: const EdgeInsets.only(top:8.0),
                     child: Row(
                    children: &lt;Widget&gt;[
                      Container(
                        //width: 200.0,
                        child: Text('From Date :',
                        style: Theme.of(context).textTheme.subtitle2.copyWith(color: Colors.black),
                        ),
                      ),            
                    ]
                  ),
                ), 
                   Container(
                         child: Column(
                           children: &lt;Widget&gt;[
                             ListTile(
                              trailing: Icon(Icons.calendar_today),
                              title: Text('$_formdate'),
                              contentPadding: EdgeInsets.only(left:4.0,right:0.0,),
                              enabled: true,
                              onTap: (){
                               _chooseDate(context);
                               } 
                            ),
                          ],
                        ),
                      ), 
                  Padding(
                     padding: const EdgeInsets.only(top:8.0),
                       child: Row(
                    children: &lt;Widget&gt;[
                      Container(
                        child: Text('To Date :',
                        style: Theme.of(context).textTheme.subtitle2.copyWith(color: Colors.black),
                        ),
                      ),            
                    ]
                  ),
                 ), 
                 Container(
                         child: Column(
                          children: &lt;Widget&gt;[
                          ListTile(
                          trailing: Icon(Icons.calendar_today),
                          title: Text('$_todate'),
                          contentPadding: EdgeInsets.only(left:4.0,right:0.0,),
                          enabled: true,
                          onTap: (){
                          _chooseData2(context);
                               } 
                            ),
                          ],
                        ),
                      ),
                  Padding(
                    padding: const EdgeInsets.only(top:8.0),
                    child: Row(
                    children: &lt;Widget&gt;[
                      Container(
                      child: Text('From Date Half leave :',
                      style: Theme.of(context).textTheme.subtitle2.copyWith(color: Colors.black),
                        ),
                      ),            
                    ]
                  ),
               ),   
          new DropdownButton&lt;String&gt;(
              dropdownColor: Colors.grey[300],
              value: currentFDHLvalue,
              isExpanded: true,
              items: _days.map((String value) {
                return new DropdownMenuItem&lt;String&gt;(
                value: value,
                  child: new Text(value),
                              );
                            }).toList(),
                            underline: Container(
                          height: 1,
                          color: Colors.black26,
              ),
                onChanged: (newValue) {             
                if (_formdate == _todate &amp;&amp; currentFDHLvalue != null) {
                  setState(() {  });
                               } else{
                                 setState((){ 
                                   currentTDHLvalue;
                                 disabledItems = false;
                                 });
                               }
                           setState(() { 
                              currentFDHLvalue = newValue;
                            }); 
                          },     
            ) ,
        Padding(
          padding: const EdgeInsets.only(top:8.0),
             child: Row(
              hildren: &lt;Widget&gt;[
              Container(
              child: Text('To Date Half leave :',
              style: Theme.of(context).textTheme.subtitle2.copyWith(color: Colors.black),
            ),
          ),            
        ]
      ),
    ),            
          new DropdownButton&lt;String&gt;(
            dropdownColor: Colors.grey[300],
              value: currentTDHLvalue,
              isExpanded: true,
              elevation: 22,
              items: _days.map((String value) {
                 return new DropdownMenuItem&lt;String&gt;(
                  value: value,
                   child: new Text(value,
                   style: TextStyle(
                    color: !disabledItems ? Colors.grey : null,
              )
            ),
          );
        }).toList(),
          underline: Container(
           height: 1,
           color: Colors.black26,
              ),
        onChanged: (newValue) {
                if (!disabledItems ? _formdate != _todate : currentTDHLvalue != newValue ) {
                  setState(() {
                    currentTDHLvalue = newValue;
                    disabledItems = false;
                  });
                }
              setState(() {
                currentTDHLvalue = newValue;
                });   
          },
  ) , 
  </code></pre>
  <p><a href="https://i.stack.imgur.com/3hx9C.png" rel="nofollow noreferrer">image</a></p>