Flutter下拉菜单位于屏幕中间,仅显示几个项目?

时间:2019-11-07 01:33:53

标签: flutter flutter-layout flutter-dependencies

当前,我正在尝试创建一个位于屏幕右侧的下拉菜单,当您单击它以选择一个砝码时,它将弹出在屏幕中间,并且仅显示一些砝码其余部分都用填充物包围,就像这张图片一样:(Just like this picture

This is what mine looks like at the minute with the code.

非常感谢您!

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,
 ),

1 个答案:

答案 0 :(得分:0)

它已经具有软件包来解决您的问题。使用此numberpicker。它还支持UI作为您提供的示例