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

Support for MacOS? #53

Closed ollyde closed 2 years ago

ollyde commented 2 years ago

Any plans to add support for MacOS?

deakjahn commented 2 years ago

No. Please, check out the README. This is a Flutter Web plugin, intentionally. There must be other plugins out there that cater for the desktop case...

ollyde commented 2 years ago

@deakjahn sorry, usually the web only projects are postfixed with _web. So flutter_dropzone_web. Also on the pubdev it says it has iOS and Android support?

deakjahn commented 2 years ago

No problem. :-) The reason is that it is a federated plugin, as also described there:

It's a federated plugin, meaning that it will compile in cross platform apps that contain both Android/iOS and Web code. It will not function on the former, the view will simply return an error text instead of a drop zone. Use if (kIsWeb) from import 'package:flutter/foundation.dart' to only use it in Flutter Web. Still, the same app will still compile to Android and iOS, without the usual dart:html errors (this is what federated plugins are for).

It really can't be done in any other way in Flutter because, apart from this federated plugin structure, there's no conditional compilation. It has to have stubs for other platforms, only that they are non-functional. Otherwise, you wouldn't be able to include it in an app that supports both mobile and web (but only uses drag-and-drop on the web). And that's why Pub reports it with support.

The only viable solution I could suggest is to use it on the web, if you need it, use whatever image/file selection you would use on mobile, and look for a third package like dnd, if it suits your use case, for the desktop case. Then, in your UI, use the various platform constants like kIsWeb to decide which UI to show in the particular case. I do the same in a mobile/web common source code app of mine.

ollyde commented 2 years ago

@deakjahn no worries, would be awesome if we had a cross platform one!