r/FlutterDev • u/yurabe • Feb 26 '21
Plugin `pub.dev`now shows desktop platform compatibility. (linux, windows, mac)
here's a screenshot: Imgur
2
2
u/sunbreakwang Feb 26 '21
https://pub.dev/packages/quick_blue
https://pub.dev/packages/quick_usb
Quite useful for cross platform plugins
3
Feb 27 '21
Those look great and I'm definitely gonna try them out this weekend, I would suggest looking at your pub score on those, you can't clear out all of them, but the ones you can will give you a huge boost to visibility.
1
1
u/sunbreakwang Feb 27 '21 edited Feb 27 '21
And I guess you may be interested in https://pub.dev/packages/libusb as well
1
u/RandalSchwartz Feb 26 '21
Unfortunately, it's not automatic. You need to declare it in your pubspec before pub publish. So there are probably many packages that are already desktop-savvy but aren't so marked. (edit: see https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms for details.)
8
u/Ultra1101 Feb 26 '21
I don't see how they would automate it anyway. It's the responsibility of package authors to maintain and manage their package, this falls under that.
3
u/RandalSchwartz Feb 26 '21
Yeah, but the ios/android/web thing was mostly automated, based on imports, I presume.
3
u/eibaan Feb 26 '21
I think, the majority of packages is platform agnostic. Only packages with native plugin code need to declare their supported platform. Everything else should be good for all Flutter variants or even for pure Dart (server-side) code.
4
u/RandalSchwartz Feb 26 '21
Well, if they import 'dart:html', they are basically web-only, unless that's behind a conditional import. Similarly, import 'dart:io' is available only on non-web platforms. So there is a bit of automation going on to detect that as I recall.
1
u/eibaan Feb 28 '21
Yes, you are right. Developers should be always aware that an import of
dart:iomakes a package platform specific. Fordart:htmlthis is more obvious and there's even a linter warning, IIRC.1
u/jopsen Mar 01 '21
I work on pub.dev, and you only need to declare platform support if you are developing a Flutter plugin. That is something that has a native component to it.
If you're developing a pure-Dart package, you don't need to declare anything, platform support is inferred depending on:
If you are importing `dart:io`, `dart:html` or `dart:js`, etc.. because these don't work everywhere (can't use `dart:html` in Android, can't use `dart:io` on the web).
Transitive imports also count.
Conditional imports are however understood.
Only imports from the main library `package:mypkg/mypkg.dart` is considered, so you can ship IO specific bits in `package:mypkg/mypkg_io.dart` as is common.
If you depend on a package that is a plugin, then you're obviously limited by whatever platforms said plugin supports.
0
24
u/vipin_malik1 Feb 26 '21
OK now I can be sure that the Web going in to Stable and desktop going beta. At last, I don't need to wait for gradle build :)