0

I'm getting images using the image_picker package and I have 2 problems.

First

How to get the image URI to upload it to Firebase storage?

This is how I get the image:

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

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

I'm getting XFile but I want to get the URI.

Second

I want to make the image circular like on Facebook and other websites. 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 I get:

Results

I want it to fit the circle.

user16217248
  • 3,119
  • 19
  • 19
  • 37
toufik s
  • 1
  • 1

0 Answers0