deakjahn / flutter_dropzone

A drag-and-drop Flutter plugin (Web). Only web and only from outside into Flutter.
https://pub.dev/packages/flutter_dropzone
85 stars 36 forks source link

Rewrite onDrop handler to handle multi files #49

Closed lasys closed 2 years ago

lasys commented 2 years ago

Currently when onDrop is called each file will be handled separately. My suggestion is that onDrop returns an array which contains all dropped files.

deakjahn commented 2 years ago

The idea is sane but it won't work this way. Being a federated plugin with a platform interface, breaking changes are very much discouraged. So, first we would need to change the interface, then adapt the rest. And even that only in a way that doesn't break current functionality.

So, I would suggest to leave onDrop as it is, to add a new onDropMultiple beside it (with all the underlying necessities like DropzoneDropMultipleEvent and more). Then everybody can decide which event to subscribe to and nobody has to change existing code.

deakjahn commented 2 years ago

OK, I changed the interface a little bit (version 2.0.5), let's follow from here.

deakjahn commented 2 years ago

@lasys because this change goes against yours, you probably want to pull the new stuff first and experiment with that. It seems to work for me all right but let's test if before publishing. :-)

lasys commented 2 years ago

Thank you for the quick response, support and implementation! Great work! You are right. It is much better to let the developer decide whether to process one file or multiple files.

I skimmed the code and it looks good to me, but to be on the safe side, I will integrate and test your new code on Monday and give you feedback then.

lasys commented 2 years ago

@deakjahn I just checked your new code and it works fine! One small suggestion: When someone adds onDrop and onDropMultiple, both handlers are executed. Maybe it is more intuitive that if more than one file is dropped and onDropMultiple is set, then only this method is called and the other way around.

deakjahn commented 2 years ago

Well, I don't know. And if they want to have both? Who knows? :-)

lasys commented 2 years ago

Nobody knows :D

So from my side, it fits and it would be great, if you release a new version.

Thanks again!

deakjahn commented 2 years ago

I think I have it.