按下按钮时不显示“颤振”对话框

时间:2019-02-06 12:01:04

标签: 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'),
          ),
        ],
    );
  }

我试图在按下按钮时实现对话框。我想从图库和照相机中选择图像,以便我创建了一个对话框来选择要上传图片的任何选项。问题是当我单击按钮对话框时可见。

1 个答案:

答案 0 :(得分:0)

您需要致电showDialog

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

        );
      });