DropdownButtonFormField 在尝试显示字符串时出错

DropdownButtonFormField gives Error when try to display String

我想制作显示如下城市的 DropdownButtonFormField:

final List<String> cities = ['London', 'New York', 'Paris', 'Shanghahai', 'Tokyo'];

String _currentCity;

DropdownButtonFormField(
            value: _currentCity ?? ' ',
            decoration: textInputDecoration,
            items: cities.map((city) {
              return DropdownMenuItem(
                value: city,
                child: Text('$city City '),
              );
            }).toList(),
            onChanged: (val) => setState(() => _currentCity = val ),
          ),

但是当我尝试显示这些字符串时出现红屏错误:

并且如果我将列表中的字符串更改为数字,则效果很好:

 final List<String> cities = ['0', '1', '2', '3', '4'];

虽然我使用字符串列表,但有人能告诉我它有什么问题吗

您可以尝试将 _currentCity 设置为默认值吗?

String _currentCity = 'London';