I am getting error as described in image. You can check error with line.
Actually, I am trying to add two options in modalBottomSheet
. the first is Camera and second is Gallery. Then if gallery is selected so, I want to navigate to the StatusImage()
page where I am passing argument of selected file. So, when I select image then it is not navigating to the StatusImage()
and showing error which is in terminal inside image.
This is takePhoto()
method.
Future<PickedFile?> takePhoto(ImageSource source) async {
// ignore: deprecated_member_use
final pickedFile = await picker.getImage(source: source);
return pickedFile;
}
This code is inside onTap:
Navigator.pop(context);
PickedFile? imageFile =
await takePhoto(ImageSource.gallery);
setState(() {
imageFile != null
? Navigator.push(
context,
MaterialPageRoute(
builder: (context) => StatusImage(
name: userName,
userId: currentUserId,
imageFile: File(imageFile.path),
)))
: Container();
imageFile;
});
Let me know where is problem exactly.