使用StatefulBuilder

_showDialogr() {showDialog(context: context,builder: (BuildContext ctx) {return StatefulBuilder(builder: (BuildContext context, StateSetter setState) {return Scaffold(body: Column(children: <Widget>[Container(height: 400,padding: EdgeInsets.fromLTRB(8, 0, 8, 8),decoration: BoxDecoration(borderRadius: BorderRadius.circular(20),color: Colors.white,),child: Column(mainAxisSize: MainAxisSize.min,children: <Widget>[SizedBox(height: 15,),Expanded(flex: 6,child: Column(mainAxisSize: MainAxisSize.min,children: <Widget>[Row(children: [Expanded(flex: 8,child: DropdownButton<String>(items: getList(),hint: Text('请选择'),value: Id,onChanged: (String? str) {setState(() { Id = str;});},elevation: 24,style: TextStyle(color: Colors.black,fontSize: 16,),),),],),],),),],),),],),);},);},);}