Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to fetch an image from gallery or camera in circle avatar?

I have created a page and added a function to import photo from gallery and camera. but I have an issue with the photo selected appearing in the circle avatar. instead of image appearing in circle avatar it appear below all the widgets. can someone say how fix it?

enter image description here

below is the call function

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

File? image;

Future pickImage() async{
try{
final image = await ImagePicker().pickImage(source: ImageSource.gallery);

if(image == null) return;

final  imageTemp = File(image.path);

setState(() => this.image = imageTemp);
} on PlatformException catch(e){
print('Failed to pick image: $e');
}
}

Future pickImageC() async{
try{
final image = await ImagePicker().pickImage(source: ImageSource.camera);

if(image == null) return;

final  imageTemp = File(image.path);

setState(() => this.image = imageTemp);

} on PlatformException catch(e){
print('Failed to pick image: $e');
}
}

>Solution :

Use Image Provide to set image in CircleAvatar.

image!=null?CircleAvatar(
            radius: 50,
            backgroundImage: FileImage(image!),
          ):Container(),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading