crop_your_image icon indicating copy to clipboard operation
crop_your_image copied to clipboard

"flutter web" crashes the browser

Open andre-ab opened this issue 11 months ago • 1 comments

The code snippet crashes the browser, image over 2 MB, hangs for more than 26s and "save" the image, more or less at the same time, I'm using the ChangeNotifier. code:

Crop(
         aspectRatio: 3 / 4,
         // When starting to load the image, 
         // the code hangs on this line
         image: controller.newImg!,
         controller: controller.cropController,
        // when saving, the code crashes on this line
         onCropped: (Uint8List img) {
               controller.saveImg(img);
         },
),
                        

open to get the image:


  Future<void> openGetImg() async {
    FilePickerResult? result = await FilePicker.platform.pickFiles(
      type: FileType.image,
    );
    if (result == null) return;
    extensionImg = result.files.first.extension;
   //  load the image for Crop
    newImg = result.files.single.bytes;
    notifyListeners();
  }
  

Save button

ElevatedButton(
  child: Text('Crop it!')
  onPressed: () => controller.cropController.crop(),
),
 

andre-ab avatar Mar 12 '24 21:03 andre-ab

@andre-ab Thank you for using and giving me feedback. I'm struggling with separating the thread to operate cropping, which is quite slow on web. Let me take some time to improve the performance on web, or if you have an idea, consider to override the cropping logic via imageCropper argument.

chooyan-eng avatar Mar 18 '24 08:03 chooyan-eng