Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dropzone view: targetplatform.windows is not supported #61

Open
Asad0473 opened this issue Jan 10, 2023 · 67 comments
Open

dropzone view: targetplatform.windows is not supported #61

Asad0473 opened this issue Jan 10, 2023 · 67 comments

Comments

@Asad0473
Copy link

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
Copy link
Owner

Could you come up with a reproducible repo?

@Asad0473
Copy link
Author

what do you mean by reproducible repo?

@deakjahn
Copy link
Owner

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
Copy link
Author

@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
Copy link
Author

@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
Copy link
Owner

deakjahn commented Jan 12, 2023

@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
Copy link
Author

Its not working on my website

@deakjahn
Copy link
Owner

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

@Asad0473
Copy link
Author

sorry its working fine in my browser

@Asad0473
Copy link
Author

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

@Asad0473
Copy link
Author

Maybe its not working for secure website

@deakjahn
Copy link
Owner

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
Copy link
Owner

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

@Asad0473
Copy link
Author

Ok i test it

@deakjahn
Copy link
Owner

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

@Asad0473
Copy link
Author

yes in dialog to post

@deakjahn
Copy link
Owner

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

@Asad0473
Copy link
Author

Asad0473 commented Jan 12, 2023

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

@deakjahn
Copy link
Owner

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
Copy link
Author

Asad0473 commented Jan 12, 2023

tttt
see this image @deakjahn

@deakjahn
Copy link
Owner

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
Copy link
Author

Can you see the above image ?

@deakjahn
Copy link
Owner

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

@deakjahn
Copy link
Owner

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

@Asad0473
Copy link
Author

Ok

@deakjahn
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

deakjahn commented Jan 12, 2023

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
Copy link
Author

So what the solution is now ?

@deakjahn
Copy link
Owner

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?

@srmncnk
Copy link

srmncnk commented Jan 27, 2023

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

@deakjahn
Copy link
Owner

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
Copy link

srmncnk commented Jan 27, 2023

Switched to drop_zone, sorry.

@Ahnaf16
Copy link

Ahnaf16 commented Feb 16, 2023

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
Copy link
Owner

@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
Copy link
Owner

deakjahn commented Feb 16, 2023

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:

static FlutterDropzonePlatform _instance = MethodChannelFlutterDropzone();

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

final self = FlutterDropzonePlugin();
_isReady = _readyCompleter.future;
html.window.addEventListener('flutter_dropzone_web_ready', (_) {
if (!_readyCompleter.isCompleted) _readyCompleter.complete(true);
});
FlutterDropzonePlatform.instance = self;

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):

throw UnsupportedError(
'DropzoneView: $defaultTargetPlatform is not supported');

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
Copy link

Ahnaf16 commented Feb 18, 2023

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:

static FlutterDropzonePlatform _instance = MethodChannelFlutterDropzone();

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

final self = FlutterDropzonePlugin();
_isReady = _readyCompleter.future;
html.window.addEventListener('flutter_dropzone_web_ready', (_) {
if (!_readyCompleter.isCompleted) _readyCompleter.complete(true);
});
FlutterDropzonePlatform.instance = self;

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):

throw UnsupportedError(
'DropzoneView: $defaultTargetPlatform is not supported');

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.

@deakjahn
Copy link
Owner

Yes, this is what federated plugins are about, all current Flutter plugins that support various platforms are expected to use this structure.

Yes, I removed that file. Flutter moved from Android embedding v1 to v2 gradually, less and less plugins and apps used the old one, so it no longer gets generated these days. I don't have it, either, but it remained in the repo. Even when it was used, it was generated automatically.

I'm glad to hear it works for you but then we didn't solve the problem this time around, either. :-) Anyway, I can only ask anybody who still experiences this issue to put a breakpoint or a log write into that registerWith() to see whether it gets called and executed properly.

@WilliamCunhaCardoso
Copy link

Facing the same problem with mac-OS.

I know the plugin is for web, and we are also building a website. When we deploy our website, such error occurs of target platform unsupported.

@deakjahn
Copy link
Owner

Then please, read the comment just above and try to apply a breakpoint or a log write to see.

@MenuItem207
Copy link

Had a similar issue that I resolved by running 'flutter clean'

@crizant
Copy link

crizant commented Aug 15, 2023

I encountered it once, also on MacOS. Didn't tweak anything, just built the flutter web once again and the error is gone.

@zeevgrim
Copy link

zeevgrim commented Oct 6, 2023

Facing the same problem with mac-OS.

I know the plugin is for the web, and we are also building a website. When we deploy our website, such an error occurs of the target platform is unsupported.

same, only after deployment.

@Ahnaf16
Copy link

Ahnaf16 commented Oct 10, 2023

for me, setting the web renderer to canvaskit when building for release solved my problem. But still don't know what exactly caused the problem.

@toco1001
Copy link

toco1001 commented Dec 1, 2023

flutter build web --web-renderer html --release works for me.

@congthanhng
Copy link

i got same, but
flutter build web --web-renderer html --release NOT works for me.

@deakjahn
Copy link
Owner

deakjahn commented Dec 5, 2023

May I reiterate my message from Feb 18? We won't be able to find it out without somebody actually seeing this problem looking into the breakpoint mentioned there...

@Rimzone
Copy link

Rimzone commented Jan 6, 2024

Had a similar issue that I resolved by running 'flutter clean'

NB

@huseyinseyit
Copy link

DropzoneView: TargetPlatform.windows is not supported.

-My project only web project not desktop or android, ios.
-There is no error log.
-Working localhost but hosting firebase and real devices, browsers don't work.

@deakjahn
Copy link
Owner

Please, have a look at #61 (comment)

@DavidOrakpo
Copy link

I'm running into this same issue as well

@DavidOrakpo
Copy link

DavidOrakpo commented Mar 16, 2024

I'm not sure how to go about the 61 comment you referenced @deakjahn. Can you break it down?
My case is exactly as has been explained above. I'm using canvas kit

Update: On further reading, I understand better now, but not fully. As the error only occurs in deployed sites, how do we debug that function?

@deakjahn
Copy link
Owner

deakjahn commented Mar 16, 2024

@DavidOrakpo As you probably found in that comment, the problem is not directly in the plugin but in Flutter not calling it when it should. As I never was able to reproduce it, I can't really determine anything until somebody whole actually experiences the issue can debug it.

This shouldn't be that hard, all browsers have very large and sophisticated Developer Tools (Ctrl+Shift+I or F12). You could find the code mentioned above and put a breakpoint, much like in any other programming environment.

@deakjahn
Copy link
Owner

deakjahn commented Jun 8, 2024

We're not yet sure whether #89 solves this. Could those of you who have problems with this try that modification?

@deakjahn deakjahn reopened this Jun 8, 2024
@deakjahn deakjahn mentioned this issue Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests