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

dropzone view: targetplatform.windows is not supported #61

Open Asad0473 opened 1 year ago

Asad0473 commented 1 year ago

I am using this library in my web app not desktop app but I am still facing this issue . its working fine in debug mode but when we go to live server or you say release mode i am facing this issue

deakjahn commented 1 year ago

Could you come up with a reproducible repo?

Asad0473 commented 1 year ago

what do you mean by reproducible repo?

deakjahn commented 1 year ago

A very small project, a minimal one, that shows the problem and allows me to reproduce it. Because, as things stand now, I can't make that error appear myself, so I have no idea what leads to it and how I can fix it.

Asad0473 commented 1 year ago

@deakjahn , here is the sample project link. please download it and make it live on server. because we are getting target platform error on our live server. in local it's working fine. our app is developed for Android, IOS, and web. but this we allowing this feature is only for web . please make it supported for Window and MacOs as well. I think it might be creating problem because this library is not supporting Windows and MacOs.

https://drive.google.com/file/d/1644K50Sx_-imnKUYcEyqlJTj58xHXkCx/view?usp=sharing

Asad0473 commented 1 year ago

@deakjahn We are working on a social media website called Werfie (https://werfie.com) which is similar to Twitter. We would love to dropzone developed by you in werfie. You will get credit for it as well in our website Credits section. I request you to please update us with the issue that we are facing while using dropzone in our website. We are expecting to launch the new version of werfie.com on Monday next week and this issue is holding the release. I request your immediate attention on this. waiting for your response...

deakjahn commented 1 year ago

@Asad0473 Then please, help me what to look for :-) I downloaded it, put it into Android Studio and built for the web. I uploaded it to my test site, temporarily at http://teszt.tramontana-teszt.hu/#/. When I start it, it starts, when I drag an image into it, it appears. I'm testing in Vivaldi, a Chrome based browser but I also tried Edge to be sure.

Asad0473 commented 1 year ago

Its not working on my website

deakjahn commented 1 year ago

But does my test at the link above work for you, in your browser?

Asad0473 commented 1 year ago

sorry its working fine in my browser

Asad0473 commented 1 year ago

but its not work for https://werfie.com/ ..

Asad0473 commented 1 year ago

Maybe its not working for secure website

deakjahn commented 1 year ago

I don't think so but I can add a cert to my test in a few minutes. In the meantime, could you do the same as I did? I built your sample simply with:

flutter build web

or

flutter build web --web-renderer canvaskit

and upload the contents of build/web to anywhere on your site into a new folder that I can access from outside?

deakjahn commented 1 year ago

It's HTTPS now: https://teszt.tramontana-teszt.hu/#/

Asad0473 commented 1 year ago

Ok i test it

deakjahn commented 1 year ago

I don't really know where you plan to use it on the site. In the dialog to send a post?

Asad0473 commented 1 year ago

yes in dialog to post

deakjahn commented 1 year ago

Right now I get a window showing the image and the browser has CORS error messages. But nothing about Windows...

Asad0473 commented 1 year ago

https://staging.werfie.com/ use this link and you see the error in post dialog

deakjahn commented 1 year ago

I tried with the real one, with a disposable e-mail, but didn't send any message. :-) I'll try to register the same here.

Asad0473 commented 1 year ago

tttt see this image @deakjahn

deakjahn commented 1 year ago

I can't register because I can't select a country, the dropdown doesn't open. It did all right on the real site, although it would be nice to have a way to use the keyboard to locate the country, there are quite a few on the Earth. ;-))

Asad0473 commented 1 year ago

Can you see the above image ?

deakjahn commented 1 year ago

Yes, sure, but I'd like to see it in action so that I can look into the browser dev console.

deakjahn commented 1 year ago

OK, I saved it, you can delete the message.

Asad0473 commented 1 year ago

Ok

deakjahn commented 1 year ago

I can see the message, but I don't yet know what Windows has to do with it. :-) There are Firebase errors in the console but that's something else.

Asad0473 commented 1 year ago

Yes i know .. I also could not find that problem its working fine in debug mode and even android release mode.. But we go to live window error is coming. I think this libaray is not for windows thats why

deakjahn commented 1 year ago

It certainly isn't, it's a web only plugin, but we're on the web now. :-) Basically, this is a federated plugin. This means that it has a central interface and implementation for platforms. In this particular case, a single implementation, nothing else: web. All the others (Android, iOS, Linux, macOS, Web) are missing because there is no sense, of course. That means that the default interface itself throws this error for any implementation: https://github.com/deakjahn/flutter_dropzone/blob/master/flutter_dropzone_platform_interface/lib/method_channel_flutter_dropzone.dart

And then, the web implementation overrides it and does the actual work: https://github.com/deakjahn/flutter_dropzone/blob/master/flutter_dropzone_web/lib/flutter_dropzone_plugin.dart

So, this is the genuine error message that you should see on anything but the web. But even then, how come Flutter thinks it's running on Windows?

Asad0473 commented 1 year ago

So what the solution is now ?

deakjahn commented 1 year ago

defaultTargetPlatform comes from the Flutter engine, package:flutter/foundation.dart, Flutter fills it with the platform it thinks it runs on. What does it say when you start the program? Could you log it somewhere when you start running?

Asad0473 commented 1 year ago

I dont see any error on log my log is clear

deakjahn commented 1 year ago

It's not necessarily important:

Screenshot 2023-01-12 214432

Asad0473 commented 1 year ago

I think this is not related to this

deakjahn commented 1 year ago

No, certainly not.

Asad0473 commented 1 year ago

By the way i used getmaterial from getx not material app

deakjahn commented 1 year ago

Well, I never did, I prefer my own classes for state management and cross platform widgets can also be done with other plugins. Can you experiment a little with this dialog? You could place a Text() anywhere and make it display this defaultTargetPlatform. If it says windows, that would be very strange.

Asad0473 commented 1 year ago

You know already do that.. I place it some other location but i got same error

deakjahn commented 1 year ago

Not a Dropzone, just a Text to see what defaultTargetPlatform says.

Asad0473 commented 1 year ago

I do not understand what are you trying to say that

deakjahn commented 1 year ago

You have that dialog with the text field to type into, the avatar of the user, the Dropzone, icon buttons at the bottom. I would add a Text() widget as well that shows the value of defaultTargetPlatform from foundation. Just for a minute, to see what is in this variable.

Asad0473 commented 1 year ago

flutter build web --web-renderer html --release i run this command and its working fine now thanks for your time and effort . I really appreciateit :-)

deakjahn commented 1 year ago

OK, that's good to hear, a temporary relief but not the solution, unfortunately, because it should have no connection with that. I only use CanvasKit since it appeared (not even in stable, but already before that) because it provides much better performance and features than the old one. Even the test I put up yesterday was CanvasKit. So, this isn't the real solution, even if it now helps you. :-)

JinHwanOh commented 1 year ago

Had same issue.. flutter build web --web-renderer html --release did the trick.

srmncnk commented 1 year ago

For me it doesn't work and I AM using html as the web renderer. I am testing this on Linux.

deakjahn commented 1 year ago

And do you all have the problem in your own, fully developed app, or maybe we can create a minimal one that can be shared here? Because I'm yet to see it and this makes it awfully hard to diagnose... :-))

srmncnk commented 1 year ago

Switched to drop_zone, sorry.

Ahnaf16 commented 1 year ago

I'm having the same problem. here is my code :

Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text('default Target Platform : $defaultTargetPlatform'),
          const SizedBox(height: 10),
          const Text('is Web : $kIsWeb'),
          const SizedBox(height: 10),
          if (kIsWeb)
            DropzoneView(
              onCreated: (controller) => dropCtrl = controller,
              onDrop: (value) {
                log(value.name);
              },
            ),
        ],
      ),

but still havingdropzone view: targetplatform.windows is not supported as output. image even though I'm on the web, defaultTargetPlatform is detecting windows cause I'm developing on windows?

deakjahn commented 1 year ago

@Ahnaf16

cause I'm developing on windows?

So do I and still I don't have the error. Strange. Yes, this shows Windows for me, too, but the drop still works all right. Anyway, I try to come up with a solution.

deakjahn commented 1 year ago

To put it into some perspective, we never actually check the platform, there's no decision based on that. Simply, this is a web plugin that has its implementation in flutter_dropzone_plugin.dart. You only get this error message if, for some reason, it doesn't register and start the plugin. As I still can't trigger the error, could you help me a bit with this? This is how it works (or is supposed to work):

We have an abstract class and the static instance is initialized with it:

https://github.com/deakjahn/flutter_dropzone/blob/903b16c22151b14c14f40cb818e58b083674ede6/flutter_dropzone_platform_interface/lib/flutter_dropzone_platform_interface.dart#L54

But as soon as the real web plugin is registered, this instance gets overwritten:

https://github.com/deakjahn/flutter_dropzone/blob/903b16c22151b14c14f40cb818e58b083674ede6/flutter_dropzone_web/lib/flutter_dropzone_plugin.dart#L20-L25

And from now on, any part that uses this instance will use the web plugin. You only get the error message if this registration doesn't work and the instance keeps the original value (where all functions lead to a very deliberate exception):

https://github.com/deakjahn/flutter_dropzone/blob/903b16c22151b14c14f40cb818e58b083674ede6/flutter_dropzone_platform_interface/lib/method_channel_flutter_dropzone.dart#L14-L15

So, the question would be if you could debug this registerWith() function, maybe with some log readouts, to see how far you can get in your code.

Ahnaf16 commented 1 year ago

To put it into some perspective, we never actually check the platform, there's no decision based on that. Simply, this is a web plugin that has its implementation in flutter_dropzone_plugin.dart. You only get this error message if, for some reason, it doesn't register and start the plugin. As I still can't trigger the error, could you help me a bit with this? This is how it works (or is supposed to work):

We have an abstract class and the static instance is initialized with it:

https://github.com/deakjahn/flutter_dropzone/blob/903b16c22151b14c14f40cb818e58b083674ede6/flutter_dropzone_platform_interface/lib/flutter_dropzone_platform_interface.dart#L54

But as soon as the real web plugin is registered, this instance gets overwritten:

https://github.com/deakjahn/flutter_dropzone/blob/903b16c22151b14c14f40cb818e58b083674ede6/flutter_dropzone_web/lib/flutter_dropzone_plugin.dart#L20-L25

And from now on, any part the uses this instance will use the web plugin. You only get the error message if this registration doesn't work and the instance keeps the original value (where all functions lead to a very deliberate exception):

https://github.com/deakjahn/flutter_dropzone/blob/903b16c22151b14c14f40cb818e58b083674ede6/flutter_dropzone_platform_interface/lib/method_channel_flutter_dropzone.dart#L14-L15

So, the question would be if you could debug this registerWith() function, maybe with some log readouts, to see how far you can get in your code.

I don't know what happened, I was away for a day. But it's working now ... I think the real web plugin failed to register for some reason. And for confirmation, do I need all 3 plugins/packages in my dependencies ?? There is a generated file : generated_plugin_registrant.dart in your example folder , which I don't have.