extended_image icon indicating copy to clipboard operation
extended_image copied to clipboard

GloblalKey ExtendedImageEditorState and then currentState is null

Open asifjavaid opened this issue 2 years ago • 6 comments

Hi guys, I am using this library for croping in the image. I am using ExtendedImage from file in GridView. I am getting GlobalKey<ExtendedImageEditorState> currentState variable NULL for some images. Can you please let me know what i am doing wrong?

Here is my code.

Container(
                                color: mListOfFiles[index].select! ? Colors.lightBlue : Colors.grey[300],
                                margin: EdgeInsets.all(5),
                                child: ExtendedImage.file(file,
                                fit: BoxFit.contain,
                                cacheRawData: true,
                                mode: ExtendedImageMode.editor,
                                  extendedImageEditorKey: mListOfFiles[index].editorKey,
                                    initEditorConfigHandler:(state){

                                        return EditorConfig(

                                          cropAspectRatio: state!.extendedImageInfo!.image.width > state.extendedImageInfo!.image.height ? ExCropAspectRatios.ratio5_4 :  ExCropAspectRatios.ratio4_5
                                        );
                                    }
                                ),
                              ),

mListOfFiles.forEach((element) async {

                                            if (element.editorKey!.currentState != null) {
                                              Uint8List? listImageCropData = await  ExCropAspectRatios.cropImageDataWithDartLibrary(state: element.editorKey!.currentState!);
                                              if(listImageCropData != null)
                                              {
                                                String fileName = basename(element.imageFile!.path);
                                                File editFile = File(
                                                    '${settings.selectedPresentationPath}/${cUserSittings.rowKey}_${appointment.phoneNumber}/${BLOBS.Cropped.toString()}/${fileName}');
                                                editFile.writeAsBytesSync(listImageCropData);

                                              }

                                            }
                                            else
                                            {
                                              print("Editkey current state is null.");
                                            }

Thank you. Asif.

asifjavaid avatar Jul 07 '22 10:07 asifjavaid

editor mode for every image in Gridview??

zmtzawqlp avatar Jul 08 '22 01:07 zmtzawqlp

@zmtzawqlp Yes the editor mode is for every image in GridView.

asifjavaid avatar Jul 13 '22 11:07 asifjavaid

Any update on this?

AlfaizCeras avatar May 12 '23 10:05 AlfaizCeras

I encountered the same problem, the image that can be loaded will not be empty currentState, and the image that cannot be loaded will be reported as empty currentState

jsonsuxing avatar Mar 13 '24 09:03 jsonsuxing

Hi @jsonsuxing after facing this problem, we had not find any solution to fix the crop in the gridview, so then we had removed the crop from GridView and instead we are cropping the image in a separate screen to crop it.

asifjavaid avatar Mar 13 '24 09:03 asifjavaid

Thanks for your reply, I didn't crop it in the GridView, but selected it from the Android album, using the.file constructor. Some images can be displayed, some can't be displayed, I'm eating out now, I need more detailed parameters I can take a look at when I get back

---- Replied Message ---- | From | Asif @.> | | Date | 03/13/2024 17:15 | | To | fluttercandies/extended_image @.> | | Cc | jsonsuxing @.>, Mention @.> | | Subject | Re: [fluttercandies/extended_image] GloblalKey ExtendedImageEditorState and then currentState is null (Issue #497) |

Hi @jsonsuxing after facing this problem, we had not find any solution to fix the crop in the gridview, so then we had removed the crop from GridView and instead we cropping the image in a separate screen to crop it.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

jsonsuxing avatar Mar 13 '24 09:03 jsonsuxing