How to handle Image.file in flutter?

Viewed 33

I'm getting Image using image_picker package and I have 2 problems,

First

how to get the image uri to uplode it to firebase storge

this is how I'm getting the image:

 //getting the image

 final ImagePicker picker = ImagePicker();
                              final img = await picker.pickImage(
                                  source: ImageSource.gallery);

                             setState(() {
                                image = img;
                              });

so Im getting XFile but I wanna get the uri

SCONDE

I want to make the image circler Facebbok and other website. I used CircleAvatar and fit: BoxFit.cover but I get the same image that the user pick its not getting round

here is my code

XFile image;
//setting the image
CircleAvatar(
             radius: 50,
             child: Image.file(File(image.path),
                                    fit: BoxFit.cover,)),
 //getting the image

 final ImagePicker picker = ImagePicker();
                              final img = await picker.pickImage(
                                  source: ImageSource.gallery);

                             setState(() {
                                image = img;
                              });

the result that I get

enter image description here

I want it to fit the circle

0 Answers
Related