无法选择Flutter下拉按钮的项目

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

我正在尝试在flutter项目中实现dropdownbutton。Dropdownbutton列表将从api中填充。我已经从api获取了列表。

但是当我选择一个项目时,它没有显示。错误消息在下面给出>

The following assertion was thrown building FutureBuilder<List<Categories>>(dirty, state: _FutureBuilderState<List<Categories>>#09534):
There should be exactly one item with [DropdownButton]'s value: Instance of 'Categories'. 
Either zero or 2 or more [DropdownMenuItem]s were detected with the same value
'package:flutter/src/material/dropdown.dart':
Failed assertion: line 805 pos 15: 'items == null  items.isEmpty  value == null ||
              items.where((DropdownMenuItem<T> item) {
                return item.value == value;
              }).length == 1'

我还在Pastebin上添加了dropdownbutton代码。

https://pastebin.com/ReJPXN6D

我正在尝试在flutter项目中实现dropdownbutton。Dropdownbutton列表将从api中填充。我已经从api获取了列表。但是当我选择一个项目时,它没有显示。 ...

android ios flutter dart flutter-layout
1个回答
2
投票
© www.soinside.com 2019 - 2024. All rights reserved.