pickimage’ is deprecated and shouldn’t be used. use imagepicker.getimage() method instead

Declare your getImage method->

PickedFile imageFile;

Future getImage(int type) async {
PickedFile pickedImage = await ImagePicker().getImage(
source: type == 1 ? ImageSource.camera : ImageSource.gallery,
imageQuality: 50);
return pickedImage;
}

Display your Picked image in the container ->

Expanded(
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageFile == null
? AssetImage('assets/illustrations/name_contact.png')
: FileImage(File(imageFile.path)),
fit: BoxFit.cover)),
),
),

Calling the GetImage Method->

new ListTile(
leading: new Icon(
Icons.photo_library,
),
title: new Text(
'Galary',
onTap: () async {
final tmpFile = await getImage(2);

setState(() {
imageFile = tmpFile;
});
}),

Similarly we can call GetImage method for Camera input with input index 1 .

All done!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store