×

    Request a Proposal

    Fill Out Our Form & We’ll be in Touch Shortly

    Type of Project



    Our Locations

    PH: +1-202-938-5932

    USA

    10630 Little Patuxent Pkwy,
    Suite 314-M7
    Columbia, MD 21044

    UK

    120 Bark Street
    6th & 7th Floor
    Bolton Lancashire, United Kingdom Bl12ax

    Australia

    443 Camp Rd, Broadmeadows
    VIC, Australia

    How do I Convert Stateless DialogBox to StateFul DialogBox? Any solution or suggestion?

    How do I Convert Stateless DialogBox to StateFul DialogBox? Any solution or suggestion?

    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),))))),
                ],
              );
            });
          });
    }
    0
    0

    Leave a Reply

    Your email address will not be published. Required fields are marked *