Flutter “颤振”下拉列表起作用,但不显示更新的值

Flutter “颤振”下拉列表起作用,但不显示更新的值,flutter,dart,Flutter,Dart,选择新选项后,“我的下拉菜单”正常工作,但新选项更改后不会更新当前显示的选项 Widget buildCarDropdown() { return Center( child: DropdownButton( hint: Text('Please choose a car make'), value: currentLease.carMake, onChanged: (newVal

选择新选项后,“我的下拉菜单”正常工作,但新选项更改后不会更新当前显示的选项

Widget buildCarDropdown() {
    return
        Center(
          child: DropdownButton(
            hint: Text('Please choose a car make'),
            value: currentLease.carMake,
            onChanged: (newValue) {
              setState(() {
                currentLease.carMake = newValue;
              });
            },
            items: carMakes.map((String make) {
              return DropdownMenuItem(
                child: new Text(make),
                value: make,
              );
            }).toList(),
          ),
        );
  }
carMakes只是一个字符串数组

currentLease包含用于选择make的字符串。在currentLease中更改该值后,会正确设置该值,如果重新加载小部件,则会正确显示该值

在我看来,这里的一切都很正常,不知道为什么不能正确显示更新


编辑:我不更新它的意思是,下拉菜单打开,显示所有选项。假设它从本田开始,你可以选择Acura,尽管currentLease.carMake得到了正确的更新,下拉列表将一直显示,直到重新加载为止。

您能解释一下您的意思吗,但新选择在更改后不会更新当前显示的选项?您是否正在初始化构建中的currentLease对象/或某种方法,但是不在state类中?所以我通过将我的保存菜单断开到它自己的小部件来修复这个问题。我认为这与SetState刷新错误的小部件有关,因为我的小部件只来自一个函数。