deakjahn / flutter_dropzone

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

[WIP] initial version #76

Closed dxvid-pts closed 6 months ago

dxvid-pts commented 7 months ago

Work in progress PR migrating dart:html to package:web

deakjahn commented 7 months ago

I tried if your repo allowed me to upload my new changes and it did (I did it with manual editing, not from the IDE, hence the several separate commits).

I also changed the internal ID of the platform control. I created the original functionality for that app back then but it ceased to exists in the meantime and the domain no longer exists, so better to use something generic.

deakjahn commented 7 months ago

Exception at https://github.com/dxvid-pts/flutter_dropzone/blob/d96f38436353d215118c700efb60d7b2c0d0c5d0/flutter_dropzone_web/lib/flutter_dropzone_plugin.dart#L42-L46 when trying to run.

dxvid-pts commented 7 months ago

How to replicate the exception? Works fine for me

deakjahn commented 7 months ago

Really? Does it work all right? Which browser did you try it in?

(I use Vivaldi for my regular browsing, don't have any other browser installed, so I simply use the otherwise unremovable Edge for Flutter web testing.)

Screenshot 2024-02-23 145334

deakjahn commented 6 months ago

@dxvid-pts Now I'm not sure whether we should be bold enough to go forward with this...

dxvid-pts commented 6 months ago

I'm sorry, I missed your comment!

In my project I am already using my fork and get no errors. I just tested it on Chrome and Firefox for desktop and on mobile (Android). Can you share the code that leads to this exception? Do you think package:web is too immature?

deakjahn commented 6 months ago

Can you share the code that leads to this exception?

Sure. The built-in example in the plugin. :-)

dxvid-pts commented 6 months ago

I see... This week is busy but I can work on it next week :-)

deakjahn commented 6 months ago

OK, let's return to it then. I checked once more and I still get the error. And I don't really know what could be illegal in the constructor web.HTMLScriptElement(), either. :-)

dxvid-pts commented 6 months ago

I encountered two bugs when trying out the example. The stack trace was not exactly the same as yours but I think it had the same cause.

I fixed both so try it out again to check if your exception still occurs. Btw flutter/wasm is now in beta so this package is perfectly set up for the coming months: https://medium.com/dartlang/history-of-js-interop-in-dart-98b06991158f

deakjahn commented 6 months ago

OK, this is promising but now I get the next error. :-)

errors.dart:297 
 Uncaught (in promise) Error: TypeError: Instance of 'LegacyJavaScriptObject': type 'LegacyJavaScriptObject' is not a subtype of type 'Uint8List'
    at Object.throw_ [as throw] (errors.dart:297:3)
    at Object._failedAsCheck (rti.dart:1385:3)
    at dart_rti.Rti.new._generalAsCheckImplementation (rti.dart:1363:3)
    at dart_rti.Rti.new._installSpecializedAsCheck (rti.dart:1258:30)
    at getFileData (flutter_dropzone_web.dart:134:31)
    at getFileData.next (<anonymous>)
    at runBody (async_patch.dart:84:54)
    at Object._async [as async] (async_patch.dart:127:5)
    at flutter_dropzone_web.FlutterDropzoneView.new.getFileData (flutter_dropzone_web.dart:133:32)

Ahh, now I see, this is something I commented out and assumed a new approach, without being able to test it at all.

dxvid-pts commented 6 months ago

I got this error as well. Check my latest commit to see how to fix it. Must be a different code line... I'm on vacation now and can't be on my computer in the next few days. I could look at it on Wednesday

deakjahn commented 6 months ago

Fair enough, I missed that change. That seems to work all right.

Let's return to it when you can and I'll have to look up again how you're supposed to do a breaking change with a plugin (not the version number part, that's simple, but the branches and tags and whatnot here in GitHub). I already did it once or twice earlier but I have long forgotten... :-)

dxvid-pts commented 6 months ago

So it works now? Great! What is left besides versioning and shouldn't it be a minor change based on semver? https://semver.org/

deakjahn commented 6 months ago

Well, it was already brought up among the issues that changing the required SDK dependencies should have been done in a breaking change... :-)) Now I'm not really sure whether this version is entirely compatible with all the Flutter environments the current one works in, so it still might be prudent.

dxvid-pts commented 6 months ago

Based on my knowledge js_iterop is only available since Dart 3.3 (https://medium.com/dartlang/dart-3-3-325bf2bf6c13) and package:web uses js_iterop internally. So only flutter versions based on Dart 3.3 or older are supported with this change.

This is how the flutter community packages have done it: https://pub.dev/packages/connectivity_plus/changelog

deakjahn commented 6 months ago

That's not the main question, I already did it twice with this package as well: https://github.com/deakjahn/flutter_dropzone/releases

Simply, I have to check out how it works now in GitHub. I have a TXT with the details that I wrote back then as a note to self but GitHub might have changed something in the meantime. :-)

deakjahn commented 6 months ago

Yes, the same issue I always run into and I don't know why. I merge here, everything is OK but I don't get the new version in my IDE (Android Studio). Updating and fetching all say everything is up-to-date, still I have the old version locally. And I always forget when the next time comes how I solved it the last time around. :-))

dxvid-pts commented 6 months ago

Nice to see this merged! In case any bug gets issued, feel free to tag me :-)

deakjahn commented 6 months ago

You can't avoid that. :-)