Error: Either zero or 2 or more [DropdownMenuItem]s were detected with the same value I/flutter (18363): 'package:flutter/src/material/dropdown.dart':

后端 未结 10 1495
借酒劲吻你
借酒劲吻你 2021-01-17 13:07

Error code Hi I\'m new to flutter and have a question about dropdownbutton regarding using the same values for multiple dropdownbutton.

From my understanding from th

10条回答
  •  误落风尘
    2021-01-17 13:39

    I have the same problem, and I solved it. The dropdown button needs items list and value. We define items and selected items, but the item chosen instance does not inside the items list.

    You should try this and fix your logic. (value ıs selected item value for user)

     var _value = itemList.isEmpty
        ? value
        : itemList.firstWhere((item) => item.value == value.value);
    

    More : https://gist.github.com/VB10/fd560694fec0a38751e798a213408001

提交回复
热议问题