Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter dialog is not displaying when button is pressed

Tags:

flutter

child: RaisedButton(
  color: const Color(0xFF5867DD),
  onPressed: (){
     updateProfilePic();           
  },



 Widget updateProfilePic(){
    return SimpleDialog(
      title: const Text('Select any option'),
             children: <Widget>[
          SimpleDialogOption(
            onPressed: () {  profileImg = ImagePicker.pickImage(source: ImageSource.gallery)
                .whenComplete(() {
              setState(() {});
            }); },
            child: const Text('open gallery'),
          ),
          SimpleDialogOption(
            onPressed: () {   profileImg = ImagePicker.pickImage(source: ImageSource.camera)
                .whenComplete(() {
              setState(() {});
            }); },
            child: const Text('open camera'),
          ),
        ],
    );
  }

I am trying to implement Dialog when the button is pressed.I want to select image from gallery and camera so that i created a dialog to select any option to upload the picture.The issue is when i click the button dialog is not visible.

like image 359
Vishali Avatar asked Feb 06 '19 12:02

Vishali


1 Answers

You need to call showDialog

showDialog(
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text(title),
          content: Text(message),

        );
      });
like image 55
Figen Güngör Avatar answered Oct 27 '22 09:10

Figen Güngör