【问题标题】:Design Rectangular Drop down widget in flutter在颤动中设计矩形下拉小部件
【发布时间】:2020-08-03 04:02:24
【问题描述】:

我正在使用下面的代码来绘制矩形 DropDownWidget

  class DropDownWidget extends StatelessWidget {
    final List<String> _dropdownValues = [
      "One",
      "Two",
      "Three",
      "Four",
      "Five"
    ]; //The list of values we want on the dropdown

    @override
    Widget build(BuildContext context) {
      return Container(
        padding: EdgeInsets.symmetric(horizontal: 10.0),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(15.0),
          border: Border.all(
              color: Colors.red, style: BorderStyle.solid, width: 0.80),
        ),
        child: DropdownButtonHideUnderline(
          child: DropdownButton(
            hint: Text('Enter'),
          items: _dropdownValues
              .map((value) => DropdownMenuItem(
                    child: Text(value),
                    value: value,
                  ))
              .toList(),
          onChanged: (String value) {},
          isExpanded: true,
          value: 'One',
        ),
      ),);
    }
  }

上面的代码给出了类似的下拉菜单

我想要这样的输出,可以吗?

【问题讨论】:

    标签: flutter flutter-layout flutter-widget


    【解决方案1】:

    试试这个,让我知道你的想法

     Material(
            elevation: 6,
            color: Colors.white,
            borderRadius: BorderRadius.circular(10.0),
            child: Padding(
              padding: EdgeInsets.fromLTRB(10, 0, 10, 20),
              child: DropdownButtonHideUnderline(
                child: DropdownButton<String>(
                  hint: ListTile(
                    title: Text(
                      'Goal for activation',
                      style: TextStyle(color: Colors.grey[600], fontSize: 14),
                    ),
                    subtitle: Text(
                      '- Choose Option -',
                      style: TextStyle(color: Colors.black, fontSize: 18),
                      textAlign: TextAlign.left,
                    ),
                  ),
                  items: _dropdownValues
                      .map((value) => DropdownMenuItem<String>(
                            child: Text(value),
                            value: value,
                          ))
                      .toList(),
                  onChanged: (String value) {},
                  isExpanded: true,
                ),
              ),
            ),
          ),
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-18
      • 2019-01-28
      • 2011-03-06
      • 2019-12-20
      • 2020-02-06
      • 2023-03-06
      • 2019-09-08
      • 2021-06-27
      相关资源
      最近更新 更多