DropdownButton需要设置初始值的时候,初始值必须是显示列表里面的值
,否则会导致弹出框异常。
比如说:你的DropdownButton的items属性使用的是list
这个列表里面的值,那么你的初始值应该在list[index]
里面取,要不就会报错。
There should be exactly one item with [DropdownButton]'s value: 0.0.
Either zero or 2 or more [DropdownMenuItem]s were detected with the same value
'package:flutter/src/material/dropdown.dart':
Failed assertion: line 834 pos 15: 'items == null || items.isEmpty || value == null ||
items.where((DropdownMenuItem<T> item) {
return item.value == value;
}).length == 1'