Dropdown selection not displaying with Flutter

后端 未结 8 2115
攒了一身酷
攒了一身酷 2021-01-12 08:56

I\' m gettings items from JSON and displaying them in a dropdown. When the person select an item from the dropdown list, I get the selection but the selected item doesn\'t c

8条回答
  •  旧巷少年郎
    2021-01-12 09:44

    Is used this code in my most recent app and it works. Maybe you could compare it to your code.

    return DropdownButton(
        style: Theme.of(context).textTheme.title,
        items: _persons.map((String val) {
          return new DropdownMenuItem(
            value: val,
            child: new Container(
              child: new Card(
                child: new Row(children: [
                  new Icon(Icons.person),
                  new Text(val),
                ]),
              ),
            ),
          );
        }).toList(),
        hint: new Card(
            child: new Row(children: [
          new Icon(Icons.person),
          new Text("check"),
        ])),
        value: _selectedPerson,
        onChanged: (newVal) {
          _selectedPerson = newVal;
          setState(() {});
        });
    

提交回复
热议问题