skip to Main Content

here’s a screenshot of the codeenter image description here

I tried calling the function onPress in GestureDetector property onTap then no errors were showing
then this was what i saw on the android emulator

2

Answers


  1. here is an exemple of how you can use onTap try soemthing like this probably you won’t have a problem.

    Future<void> _showSelectionDialog(BuildContext context) {
        return showDialog(
            context: context,
            builder: (BuildContext context) {
              return AlertDialog(
                  title: Text("From where do you want to take the photo?"),
                  content: SingleChildScrollView(
                    child: ListBody(
                      children: <Widget>[
                        GestureDetector(
                          child: Text("Gallery"),
                          onTap: () {
                            _openImagePicker(ImageSource.gallery);
                          },
                        ),
                        Padding(padding: EdgeInsets.all(8.0)),
                        GestureDetector(
                          child: Text("Camera"),
                          onTap: () {
                            takePhoto(ImageSource.camera);
                          },
                        )
                      ],
                    ),
                  ));
            });
      }
    
    Login or Signup to reply.
  2. Change final Function onPress; to final void Function() onPress; or final VoidCallback onPress;, both are the same.

    Then you can call the function inside widget as onTap: onPress.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search