I trying to get Image from Simulator but it crashes when click as the below GIF:
and this is the code snippet:
Widget buildImage() => GestureDetector(
child: buildAvatar(),
onTap: () async {
final image =
await ImagePicker().getImage(source: ImageSource.gallery);
if (image == null) return;
final directory = await getApplicationDocumentsDirectory();
final id = '_${widget.idUser}_${Uuid().v4()}';
final imageFile = File('${directory.path}/${id}_avatar.png');
final newImage = await File(image.path).copy(imageFile.path);
setState(() => user = user.copy(imagePath: newImage.path));
},
);
and this is the error:
Note that it works fine on real Android device

