flutter - Is there a way to add rounded corners to a DropdownButton menu item list in Flutter?
问题描述
I am trying to add rounded corners to a DropdownButton menu items list. I want to add rounded corners to the actual menu item list, not the DropdownButton.
Is there a way to do this?
解决方案
It doesn't seem to be possible to do that with a DropdownButton
, you could achieve that with a PopupMenuButton
, like this:
int _selected = 1;
Center(
child: PopupMenuButton(
child: Container(
padding: EdgeInsets.all(8.0),
color: Colors.lightBlueAccent,
child: Text('Selected item: $_selected'),
),
onSelected: (value) => setState(() => _selected = value),
color: Colors.greenAccent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(16.0))),
itemBuilder: (context) {
return [1, 2, 3]
.map((value) => PopupMenuItem(
value: value,
child: Container(
child: Text('$value'),
)))
.toList();
},
),
)
推荐阅读
- c# - 为什么要为最简单的单例实现提供私有字段?
- angular-translate - fread 提示
- swift - 加载视图后更新页面中的内容
- time - Kotlin中的Hashset toList()时间复杂度,它是否恒定?
- arduino - Arduino:如何将纪元以毫秒为单位转换为纪元
- r - 使用 levelplot 或 spplot 调整颜色键/颜色条/图例与绘图之间的间隙
- javascript - 首次访问网站空白页
- angular - 如何使用从 Spring Boot REST API 生成的 Angular 客户端?
- c++ - 我无法使用仅直接状态访问的顶点数组对象设置来显示我的 OpenGL 4.5“hello-world”三角形
- c# - Array.IndexOf 在 C# 中是如何实现的?