颤振中的下拉按钮

时间:2020-08-27 14:44:32

标签: flutter flutter-layout flutter-dependencies flutter-web

我想像这样进行下拉,我已经添加了sizebox(width:20),但是什么也没发生This my Dropdown now,对不起,这是我第一次使用flutter,这是我的代码

容器(

        margin: EdgeInsets.symmetric(horizontal: 20),
        height: 60,
        width: double.infinity,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(25),
          border: Border.all(color: Colors.black38),
        ),
        child: Stack(
          children: <Widget>[
                Icon(
                Icons.pin_drop,
                color: Colors.orange,
                size: 36,
            ),
            SizedBox(width: 20,),
            Expanded(
              child: DropdownButton(
                isExpanded: true,
                underline: SizedBox(),
                icon: Icon(
                  Icons.arrow_drop_down,
                ),
                value: "Jl. P. Diponegoro",
                items: ['Jl. P. Diponegoro', 'Jl. Juanda', 'Jl. Perjuangan']
                    .map<DropdownMenuItem<String>>((String value) {
                  return DropdownMenuItem<String>(
                    value: value,
                    child: Text(value),
                  );
                }).toList(),
                onChanged: (value) {},
              ),
            ),
          ],
        ),
      ),

1 个答案:

答案 0 :(得分:3)

我想这就是你想要的-

 Container(
              margin: EdgeInsets.symmetric(horizontal: 20),
              padding: EdgeInsets.only(left: 10.0,right: 10.0),
              height: 60,
              width: double.infinity,
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(25),
                border: Border.all(color: Colors.black38),
              ),
              child: Row(
                children: [
                  Icon(
                    Icons.pin_drop,
                    color: Colors.orange,
                    size: 36,
                  ),
                  SizedBox(width: 20,),
                  Expanded(
                    child: DropdownButton(
                      isExpanded: true,
                      underline: SizedBox(),
                      icon: Icon(
                        Icons.arrow_drop_down,
                      ),
                      value: "Jl. P. Diponegoro",
                      items: ['Jl. P. Diponegoro', 'Jl. Juanda', 'Jl. Perjuangan']
                          .map<DropdownMenuItem<String>>((String value) {
                        return DropdownMenuItem<String>(
                          value: value,
                          child: Text(value),
                        );
                      }).toList(),
                      onChanged: (value) {},
                    ),
                  ),
                ],
              ),
            ),

它看起来像这样-

enter image description here enter image description here