Drop down menu 颤振中的DropdownButton小部件不接受报价中的数字

Drop down menu 颤振中的DropdownButton小部件不接受报价中的数字,drop-down-menu,dart,flutter,Drop Down Menu,Dart,Flutter,我有一个如下所示的小部件,只要项目是字母就可以工作,但一旦我将它们切换为单引号中的数字,它就会停止工作,并出现以下错误: I/flutter (31770): The following assertion was thrown building ScopedModelDescendant<MainModel>(dirty): I/flutter (31770): 'package:flutter/src/material/dropdown.dart': F

我有一个如下所示的小部件,只要项目是字母就可以工作,但一旦我将它们切换为单引号中的数字,它就会停止工作,并出现以下错误:

    I/flutter (31770): The following assertion was thrown 
    building ScopedModelDescendant<MainModel>(dirty):
    I/flutter (31770): 'package:flutter/src/material/dropdown.dart': Failed 
    assertion: line 481 pos 15: 'value == null ||
    I/flutter (31770): items.where((DropdownMenuItem<T> item) => item.value 
    == value).length == 1': is not true.
I/flatter(31770):抛出了以下断言
建筑范围建模场景(脏):
I/flatter(31770):“包:flatter/src/material/dropdown.dart”:失败
断言:第481行第15位:“值==null||
I/颤振(31770):项目。其中((DropdownMenuItem)=>item.value
==值)。长度==1':不为真。
下面是实际的小部件:

      Widget _buildServingDropdownButton(Product product) {
if (product != null) {
  topperValue = product.topper;
}
return Padding(
  padding: const EdgeInsets.all(0.0),
  child: Column(
    mainAxisAlignment: MainAxisAlignment.start,
    children: <Widget>[
      ListTile(
        title: const Text('Topper'),
        trailing: DropdownButton<String>(
            hint: Text('Choose'),
            onChanged: (String value) {
              setState(() {
                topperValue = value;

                print(topperValue);
              });
            },
            value: topperValue,
            items: <String>[
              '1',
            ].map((String value) {
              return DropdownMenuItem<String>(
                value: value,
                child: Text(value),
              );
            }).toList()),
      ),
    ],
  ),
);
}
Widget\u buildServingDropdownButton(产品){
如果(产品!=null){
topperValue=product.topper;
}
返回填充(
填充:常量边集全部(0.0),
子:列(
mainAxisAlignment:mainAxisAlignment.start,
儿童:[
列表砖(
标题:常量文本('Topper'),
拖尾:下拉按钮(
提示:文本('Choose'),
onChanged:(字符串值){
设置状态(){
topperValue=价值;
打印(最高值);
});
},
value:topperValue,
项目:[
'1',
].map((字符串值){
返回下拉菜单项(
价值:价值,
子项:文本(值),
);
}).toList()),
),
],
),
);
}

当指定的值在
下拉菜单项中不可用时,会发生此错误

您刚刚定义了一项:

items: <String>[
          '1',
        ]

“topperValue”和“product.topper”的类型是什么?@diegoveloper topperValue是string和product.topper是string-tooth可能是它,但我不确定它怎么不可用,因为我用赋值“1”声明了它,甚至删除了if语句,我必须查看代码,看看值在哪里变化。
if (product != null) {
   topperValue = product.topper;  //different from '1' 
 }

value: topperValue,