hsbijarniya / image_editor_plus

Flutter Image Editor Plugin with simple, easy support for image editing using Paints, Text, Filters, Emoji and Sticker like stories.
MIT License
103 stars 103 forks source link

Exception: No image to work with, provide an image or allow the image picker. #51

Closed waheedahmadbhatti closed 10 months ago

waheedahmadbhatti commented 10 months ago

In Multiple Image editing they give the issue when i select the image. Working Correctly for One Image

Use Case

Using Image Picker

   final files = await _fileChooserService.chooseMultipleFiles(
      source: fileSource,
    );

Passing Images to Image Editor

   if (fileSource.isImage) {
        List<Uint8List> imageBytesList = [];
        for (var file in files) {
          List<int> bytes = await file.readAsBytes();
          imageBytesList.add(Uint8List.fromList(bytes));
        }

        var editedImages = await Navigator.push(
          context,
          MaterialPageRoute(
            builder: (context) => ImageEditor(
              images: imageBytesList,
              allowMultiple: false,
            ),
          ),
        );

        if (editedImages != null && editedImages is List<Uint8List>) {
          filesCustomData!.addAll(editedImages.map((image) => CustomFileData(file:File.fromRawPath(image) )).toList());
        }
      }
waheedahmadbhatti commented 10 months ago

Cose of the Problem

   if (images != null && image == null && !allowCamera && !allowGallery) {
      throw Exception(
          'No image to work with, provide an image or allow the image picker.');
    }

Why it's important to Allow the Camera and Gallery

 allowGallery: true,
 allowCamera: true,
hsbijarniya commented 10 months ago

fixed in v0.2.6