Images taken with camera not displaying correctly in flutter

64 Views Asked by At

Any images taken with the rear camera do not render correctly in my flutter app whether I pick from the gallery or take a new photo. The device I'm testing with is an iPhone 13 pro.

Photos that were taken with the front facing camera along with screenshots and any other image not taken with the rear camera seem to display correctly.

Here is the function used to access the image gallery using image_picker package recommended by flutter:

Future<void> _pickPhoto(BuildContext context) async {
final provider = ref.read(createBusinessProvider);
final picker = ImagePicker();

final imageFile = await picker.pickImage(
  source: ImageSource.gallery,
  imageQuality: 25,
  requestFullMetadata: true,
);

Navigator.pop(context);

setState(() {
  _imageSelected = File(
    imageFile!.path,
  );
  provider.addPhotos(_imageSelected!, widget.index);
  widget.photoSelectedCallback();
  print('PHOTO SELECTED: ${provider.photoSelected}');
});


}

  @override
  void initState() {
    super.initState();
  }

This function is called onTap of a button. The image is stored against this property:

File? _imageSelected;

I am displaying the image in a container widget like this:

Container(
            clipBehavior: Clip.hardEdge,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(8),
              image: (_imageSelected != null)
                  ? DecorationImage(
                      image: FileImage(_imageSelected!), fit: BoxFit.cover)
                  : null,
              border: Border.all(
                width: 2,
                color: JabiColors.jabiMain.withAlpha(50),
              ),
            ),
            height: double.infinity,
          ),

Image is selected fine but does not display correctly. On the device it shows a blank yellowish/beige colour. I took a screenshot to show you below but in the screenshot that yellowish colour doesn't appear, instead just plain white:

enter image description here

No errors show in the console. This is one of many instances of the same issue throughout the app. This only started happening after Flutter 3.10 upgrade, a lot of this code pre-existed but didn't exhibit this behaviour before.

What could be the issue here?

0

There are 0 best solutions below