'Why won't my image show up after picking from image_picker in Flutter?

I have been using image_picker: ^0.8.4+9 for the past couple of months with no problems. Today whenever I try to pick an image the gallery opens and I am able to pick an image, however once thats done the image doesn't appear on the screen. No errors and I update my github with it everyday and checked to see if something was changed but nothing was. I've tried using other versions only to have the same problem. I understand that this is an issue with M1 Macs sometimes, however why would it suddenly stop working using the same version? I have seen other questions similar like this. I have the correct permissions and there hasn't been a thing changed since it was last working. This could be a problem I cannot fix due to it being an iOS issue or something else but I wanted to see if anyone else is having this issue. Can't test on a physical device since I am on iOS beta but still it was working on the sim so that shouldn't matter.

Here is the basic function of getting am image and storing it:

File? pickedImage;
  Future pickImage() async {
    final _imagePicker = ImagePicker();
    final pickedImage =
        await _imagePicker.pickImage(source: ImageSource.gallery);
    final imageTemp = File(pickedImage!.path);
    setState(() => this.pickedImage = imageTemp);
  }

Here is the button to initiate the gallery and pick the image:

ElevatedButton(
                onPressed: () async {
                final _imagePicker = ImagePicker();
                final pickedImage = await _imagePicker.pickImage(
                    source: ImageSource.gallery);
                final imageTemp = File(pickedImage!.path);
                setState(() => this.pickedImage = imageTemp);
              },
              child: const Text('Add Image')),
          const SizedBox(height: 20),
          // The image should show here if not null else the 'No image' text
          pickedImage != null
              ? Image.file(pickedImage!, height: 200, width: 200)
              : Text('No Image'),

EDIT: As Vandad linked in the comment below, it seems this is a newer issue. Here is the discussion. github.com/flutter/flutter/issues/98569



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source