flutter-quill icon indicating copy to clipboard operation
flutter-quill copied to clipboard

How to select multiple images at a time in Mobile

Open MaheshManoharan opened this issue 2 years ago • 5 comments

My issue is about [Mobile]

typedef OnImagePickCallback = Future<String?> Function(File file);

QuillToolbar.basic( color: darkTheme == true ? Colors.black : Colors.white, controller: _controller, embedButtons: FlutterQuillEmbeds.buttons( onImagePickCallback: _onImagePickCallback), ),

By default, I can only select one image at a time, but how to select multiple images in Flutter quill ^7.1.4

Future<String?> _onImagePickCallback(File file) async { if (file == null) return null; // Copies the picked file from temporary cache to applications directory Directory appDocDir = await getApplicationDocumentsDirectory();

int sizeInBytes = file.lengthSync();
double sizeInMb = sizeInBytes / (1024 * 1024);
print(sizeInMb);
if (sizeInMb > 0.25) {
  file = (await FlutterImageCompress.compressAndGetFile(
      file.absolute.path, '${appDocDir.path}/${basename(file.path)}',
      quality: 20))!;
  print(file.lengthSync());
} else {
  file = await file.copy('${appDocDir.path}/${basename(file.path)}');
}
print(file.path);
return file.path.toString();

}

MaheshManoharan avatar Oct 23 '23 06:10 MaheshManoharan

Sorry but the flutter_quill_extensions image embed builder doesn't support selecting multiple images yet but we will look into that in the future

EchoEllet avatar Oct 23 '23 16:10 EchoEllet

Is there any other way I can achieve it in code?

MaheshManoharan avatar Oct 24 '23 14:10 MaheshManoharan

Is there any other way I can achieve it in code?

As far as I know, you will need custom image embed builder

EchoEllet avatar Oct 25 '23 02:10 EchoEllet

how to make that one ? any example or reference or a small description to achieve that.

MaheshManoharan avatar Oct 25 '23 05:10 MaheshManoharan

how to make that one ? any example or reference or a small description to achieve that.

You need to create a custom embed builder in order to achieve that

You will find it in the README.md

and to use it pass the embed builder in the QuillEditor configurations

EchoEllet avatar Oct 26 '23 13:10 EchoEllet