Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何根据颤振中的条件启用/禁用下拉按钮?_Flutter_Dart_Dropdownbutton - Fatal编程技术网

Flutter 如何根据颤振中的条件启用/禁用下拉按钮?

Flutter 如何根据颤振中的条件启用/禁用下拉按钮?,flutter,dart,dropdownbutton,Flutter,Dart,Dropdownbutton,我在颤振方面是新手,我正在申请休假,因为我已经创建了两个下拉按钮。其中一个下拉按钮用于自日期半休:的,第二个下拉按钮用于自日期半休的。我在两个下拉按钮中显示相同的项目列表。 问题是,当我从“开始日期半假”中选择相同的项目时,它应该不要在第二个下拉按钮中隐藏相同的选项,这意味着在“结束日期半假”中 例如,我想这样做,如果从日期和到日期相同,那么它在两个下拉按钮中的显示选项都相同,但是当用户从从日期半假中选择一个项目时,它会在到日期半假中隐藏项目选项。如果从日期开始和到日期不同,则在从日期半假和到日

我在颤振方面是新手,我正在申请休假,因为我已经创建了两个下拉按钮。其中一个下拉按钮用于自日期半休:的,第二个下拉按钮用于自日期半休的。我在两个下拉按钮中显示相同的项目列表。 问题是,当我从“开始日期半假”中选择相同的项目时,它应该不要在第二个下拉按钮中隐藏相同的选项,这意味着在“结束日期半假”中

例如,我想这样做,如果从日期到日期相同,那么它在两个下拉按钮中的显示选项都相同,但是当用户从从日期半假中选择一个项目时,它会在到日期半假中隐藏项目选项。如果从日期开始到日期不同,则在从日期半假到日期半假中显示相反的选项,如从日期半假选择上午,然后在到日期半假中我不显示上午选项,只显示下午如果自日期半假至日期半假不同,则仅此选项不同我不能这样做,请帮帮我。

我的代码如下:我只是尝试在开始日期结束日期与用户选择开始日期半假下拉按钮项目时禁用结束日期半假中的项目

var_days=[“上午”、“下午”和]

    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;
              });   
        },
) , 
填充(
填充:仅限常量边集(顶部:8.0),
孩子:排(
儿童:[
容器(
//宽度:200.0,
子项:文本('起始日期:',
样式:Theme.of(context).textTheme.subtitle2.copyWith(颜色:Colors.black),
),
),            
]
),
), 
容器(
子:列(
儿童:[
列表砖(
尾随:图标(今天的图标。日历),
标题:文本(“$\u formdate”),
contentPadding:EdgeInsets.only(左:4.0,右:0.0,),
启用:对,
onTap:(){
_选择稳重(上下文);
} 
),
],
),
), 
填充物(
填充:仅限常量边集(顶部:8.0),
孩子:排(
儿童:[
容器(
子项:文本('到目前为止:',
样式:Theme.of(context).textTheme.subtitle2.copyWith(颜色:Colors.black),
),
),            
]
),
), 
容器(
子:列(
儿童:[
列表砖(
尾随:图标(今天的图标。日历),
标题:文本(“$\u todate”),
contentPadding:EdgeInsets.only(左:4.0,右:0.0,),
启用:对,
onTap:(){
_选择A2(上下文);
} 
),
],
),
),
填充物(
填充:仅限常量边集(顶部:8.0),
孩子:排(
儿童:[
容器(
子项:文本('从休假日期起:',
样式:Theme.of(context).textTheme.subtitle2.copyWith(颜色:Colors.black),
),
),            
]
),
),   
新下拉按钮(
dropdownColor:颜色。灰色[300],
值:currentFDHLvalue,
是的,
项目:_days.map((字符串值){
返回新的DropdownMenuItem(
价值:价值,
子项:新文本(值),
);
}).toList(),
下划线:容器(
身高:1,,
颜色:颜色。黑色,
),
onChanged:(newValue){
如果(_formdate==_todate&¤tFDHLvalue!=null){
setState((){});
}否则{
设置状态((){
当前TDHL值;
disabledItems=false;
});
}
设置状态((){
currentFDHLvalue=新值;
}); 
},     
) ,
填充物(
填充:仅限常量边集(顶部:8.0),
孩子:排(
儿童:[
容器(
子项:文本('到目前为止的半假:',
样式:Theme.of(context).textTheme.subtitle2.copyWith(颜色:Colors.black),
),
),            
]
),
),            
新下拉按钮(
dropdownColor:颜色。灰色[300],
值:currentTDHLvalue,
是的,
海拔:22,
项目:_days.map((字符串值){
还新