I am new in flutter and i am making leave application in that I have create two DropdownButton. In that one DropdownButton for From Date Half Leave: and Second one for To Date Half Leave. I am showing Same Item list in both DropdownButton. Problem is that when i select same item from the From Date Half Leave then it should do not hide the same options in second DropdownButton it means in the To Date Half Leave .
For example,i want to do that if From date and To date Are same then its show option in both dropdownbutton but when user Select the one item from From Date Half Leave then it hide the item option in To Date Half Leave. and if From date and To date are different then it show opposite option in From Date Half Leave and To Date Half Leave like if From Date Half Leave select Morning then in To Date Half Leave i does not show morning option its show only Afternoon option if the From Date Half Leave and To Date Half Leave are different then only. I can't able to do this so help me please..
My Code Below: i just try to make disable the items of To Date Half Leave when the From Date and To Date are same the when user select From Date Half Leave dropdownbutton item the its disable the items in To Date Half Leave .
var _days = ['Morning', 'Afternoon',];
Padding(
padding: const EdgeInsets.only(top:8.0),
child: Row(
children: <Widget>[
Container(
//width: 200.0,
child: Text('From Date :',
style: Theme.of(context).textTheme.subtitle2.copyWith(color: Colors.black),
),
),
]
),
),
Container(
child: Column(
children: <Widget>[
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: <Widget>[
Container(
child: Text('To Date :',
style: Theme.of(context).textTheme.subtitle2.copyWith(color: Colors.black),
),
),
]
),
),
Container(
child: Column(
children: <Widget>[
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: <Widget>[
Container(
child: Text('From Date Half leave :',
style: Theme.of(context).textTheme.subtitle2.copyWith(color: Colors.black),
),
),
]
),
),
new DropdownButton<String>(
dropdownColor: Colors.grey[300],
value: currentFDHLvalue,
isExpanded: true,
items: _days.map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
underline: Container(
height: 1,
color: Colors.black26,
),
onChanged: (newValue) {
if (_formdate == _todate && currentFDHLvalue != null) {
setState(() { });
} else{
setState((){
currentTDHLvalue;
disabledItems = false;
});
}
setState(() {
currentFDHLvalue = newValue;
});
},
) ,
Padding(
padding: const EdgeInsets.only(top:8.0),
child: Row(
hildren: <Widget>[
Container(
child: Text('To Date Half leave :',
style: Theme.of(context).textTheme.subtitle2.copyWith(color: Colors.black),
),
),
]
),
),
new DropdownButton<String>(
dropdownColor: Colors.grey[300],
value: currentTDHLvalue,
isExpanded: true,
elevation: 22,
items: _days.map((String value) {
return new DropdownMenuItem<String>(
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;
});
},
) ,