flutter - Flutter Dropdown 在屏幕中间居中并且只显示几个项目?
问题描述
目前我正在尝试创建一个位于屏幕右侧的下拉菜单,当您单击它以选择权重时,它将在屏幕中间弹出并仅显示一些权重,其余的它被填充包围,就像这张图片:(就像这张图片)
太感谢了!
class Weight {
int amount;
Weight(this.amount);
static List<Weight> getWeight() {
return <Weight>[
Weight(66),
Weight(67),
Weight(68),
Weight(69),
Weight(70),
Weight(71),
Weight(72),
Weight(73),
Weight(74),
Weight(75),
Weight(76),
];
}
static List<DropdownMenuItem<Weight>> buildDropdownMenuItemsWeight(
List weightAmount) {
List<DropdownMenuItem<Weight>> items = List();
for (Weight weight in weightAmount) {
items.add(DropdownMenuItem(
value: weight,
child: Text('${weight.amount} Lbs'),
));
}
return items;
}
// Bottom that I'm using on the other page, to reference the above class to display the items in dropdown.
DropdownButton(
value: _selectedWeightSystem,
items: _dropdownMenuItems,
onChanged: onChangeDropdownItemWeightSystem,
),
解决方案
它已经有了解决您问题的软件包。使用这个数字选择器。它还支持 UI 作为您给出的示例
推荐阅读
- selenium - Selenium 的端口是什么意思?
- java-8 - Java8 流条件处理
- google-bigquery - 将 table_id 添加到 BigQuery 中多个表的结果中
- python - 在 Maya Python 中更新对象名称的问题
- html - 如何将“-”放入表单html
- c# - 在 Xamarin android 活动之间传递数据
- reactjs - React 有时不使用更新的源文件
- amazon-eks - Populating AWS Alb Ingress Annotations from ConfigMap
- python - 如何防止在 django 中提交带有空 CKEditor 的表单
- html - 如何从轮播引导程序中删除灰色空间