我创建了Flutter表单,并使用flutter构建了一个下拉按钮。我正在将本地子数据丢失到下拉列表中。我的某些下拉菜单项很长。我使用SafeArea和ListView,并且在右边溢出。
另一个问题未提及的部分解决方案,我在这里得到了答案。
知道如何解决吗?
// TODO: BUILD RUN return new Scaffold( key: _scaffoldKey, body: new SafeArea( top: false, bottom: false, child: new Form( key: _formKey, child: new ListView( padding: const EdgeInsets.symmetric( horizontal: 16.0, vertical: 32.0), children: <Widget>[ //TODO: CURRENCY new FormField<String>( builder: (FormFieldState<String> state) { return InputDecorator( decoration: InputDecoration( labelText: 'CHOOSE CURRENCY', labelStyle: TextStyle( fontSize: 18.0, fontWeight: FontWeight.bold, color: Colors.green.shade700), errorText: state.hasError ? state.errorText : null, ), isEmpty: _mySelectedCurrency == '', child: new DropdownButtonHideUnderline( child: new DropdownButton<String>( style: TextStyle( fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w500, ), value: _mySelectedCurrency, isDense: true, onChanged: (String newValue) { setState(() { _mySelectedCurrency = newValue; state.didChange(newValue); }); }, items: _itemsName, ), ), ); }, validator: (val) { return val != '' ? null : 'Choose Currency...'; }, ), ], ))));
尽管我已将问题标记为可能重复,但另一个问题中未提及的部分解决方案是将该isExpanded属性用于DropDownButton。
isExpanded
DropDownButton
child: new DropdownButton<String>( isExpanded: true, ...