Reputation:
When I tap on a GestureDetector it opens a dialog where I am able to select, if I want to take the picture from the gallery or to make a photo on my own (the plugin). But my problem is when I click on one of the buttons on the dialog, the dialog pops up again and only after that, it's possible to take a picture from the camera or the gallery. It would be great, if someone could help me with this problem.
This is the GestureDetector:
GestureDetector(
child: Container(
child: (_image == null
? CircleAvatar(child: Icon(Icons.photo))
: FileImage(_image)
)
),
onTap: () async{
switch(await dialogs.takePhoto(context)){
case "take":
getImage(ImageSource.camera);
break;
case "pick":
getImage(ImageSource.gallery);
break;
}
},
)
The call dialogs.takePhoto(context)
ends here:
takePhoto(BuildContext context){
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext ctxt){
return AlertDialog(
title: Text("Change Photo"),
content: Container(
child: Column(
children: <Widget>[
InkWell(
child: Text("Take photo"),
onTap: ()=> Navigator.pop(ctxt, "take"),
),
InkWell(
child: Text("Pick photo"),
onTap: ()=> Navigator.pop(ctxt, "pick"),
),
],
),
),
actions: <Widget>[
FlatButton(
child: Text(
"Abort"
),
onPressed: ()=>Navigator.pop(ctxt),
)
],
);
}
);
}
Thanks in advance !
SOLUTION
Found the solution exactly the moment where I clicked on the submit button. The problem was that I called the function to pick the image twice XD.
Upvotes: 3
Views: 4294
Reputation:
Found the solution exactly the moment where I clicked on the submit button. The problem was that I called the function to pick the image twice XD.
Upvotes: 1