Flutter下拉列表位于屏幕中间,仅显示一些项目?

问题描述 投票:1回答:1

当前,我正在尝试创建一个位于屏幕右侧的下拉菜单,当您单击它以选择一个重量时,它将在屏幕中间弹出,并且仅显示一些重量和其余部分都用填充物包围,就像这张图片一样:([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,
 ),
flutter flutter-layout flutter-dependencies
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.