let me explain How can I set a maximum number of files to pick for filepicker so that I can limit the pick of file so it does not overload the server.
let me explain How can I set a maximum number of files to pick for filepicker so that I can limit the pick of file so it does not overload the server.
imagePicker does not allow selecting a specific count. I don't think Java does either without developing your own custom gallery. imagePicker just calls to platform code in any case and if that platform doesn't support I think we're out of luck.
One thing you can do is allow the user to pick as many images as they want (so just regular multi image pick) but then just take however many you need then show a toast that says only count number of photos were used. This feels like a decent trade off.
I have solved this by this block of code
Future galleryImage() async {
if (images.length == 0 || images.length < 4) {
var pics = await ImagePicker().pickMultiImage(imageQuality: 10);
if (pics != null && pics.length < 5) {
photos = pics;
pics.forEach((element) {
images.add(File(element.path));
update();
print('length: ${images.length}');
});
update();
}