Solution : To convert Stateless dialogbox to Stateful DialogBox we use “StatefulBuilder”
Code Example :
Future<void> showInformationDialog(BuildContext context) async { return await showDialog( context: context, builder: (context) { bool isChecked = false; return StatefulBuilder(builder: (context, setState) { return AlertDialog( title: Center( child: Text("Reschedule Your Date And Time ", style: TextStyle( fontSize: 14, fontWeight: FontWeight.bold, color: Colors.black, ), ), ), content: Expanded( child: Container( height: MediaQuery.of(context).size.height*0.19, width: MediaQuery.of(context).size.width*0.6, child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Container( width: MediaQuery.of(context).size.width* 0.38, padding: EdgeInsets.symmetric(horizontal: 5,vertical: 3), decoration: BoxDecoration( color:inputField, borderRadius: BorderRadius.circular(8), ), child: TextButton( onPressed: ()async { await _pickDate(context); setState((){}); }, child:Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text("${pickedData.year}/ ${pickedData.month}/ ${pickedData.day}", style: TextStyle( fontWeight: FontWeight.w500, color: Colors.black, fontSize: 14.0 ), ), Container( decoration: BoxDecoration( color: inputField, borderRadius: BorderRadius.circular(5.0), image: DecorationImage( image: Svg("assets/Assets/10/calender.svg"), fit: BoxFit.cover, ), ), height: 30, width: 30, ), ], ), ), ), SizedBox(height: 5,), Container( width: MediaQuery.of(context).size.width* 0.38, padding: EdgeInsets.symmetric(horizontal: 5,vertical: 3), decoration: BoxDecoration( color: inputField, borderRadius: BorderRadius.circular(8), ), child: TextButton( onPressed: () { _pickTime(); }, child:Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ AlegreyaStyleWidget( text: time.hour.toString()+":"+time.minute.toString(), fontWeight: FontWeight.w800, fontColor: mainHeading, fontSize: 14.0, ), Container( decoration: BoxDecoration( color: inputField, borderRadius: BorderRadius.circular(5.0), image: DecorationImage( image: Svg("assets/Assets/10/timer.svg"), fit: BoxFit.cover, ), ), height: 30, width: 30, ), ], ), ), ), ], ), ), ), actions: [ TextButton( onPressed: (){ Navigator.pop(context); }, child: Center(child: Container( decoration: BoxDecoration( color: btColor, borderRadius: BorderRadius.circular(5), ), height: 30, width: 100, child: Center(child: Text("SUBMIT",style: TextStyle(fontWeight: FontWeight.bold,color:Colors.black),))))), ], ); }); }); }