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
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); }, ) ], ), )); }); }
Change final Function onPress; to final void Function() onPress; or final VoidCallback onPress;, both are the same.
final Function onPress;
final void Function() onPress;
final VoidCallback onPress;
Then you can call the function inside widget as onTap: onPress.
onTap: onPress
Click here to cancel reply.
2
Answers
here is an exemple of how you can use onTap try soemthing like this probably you won’t have a problem.
Change
final Function onPress;
tofinal void Function() onPress;
orfinal VoidCallback onPress;
, both are the same.Then you can call the function inside widget as
onTap: onPress
.