r/FlutterDev • • Feb 26 '21

Plugin `pub.dev`now shows desktop platform compatibility. (linux, windows, mac)

here's a screenshot: Imgur

107 Upvotes

16 comments sorted by

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

2

u/Fmatosqg Feb 27 '21

First time Android comes before iOS and Linux before windows.

2

u/kgainz Feb 26 '21

This is a great step forward.

2

u/sunbreakwang Feb 26 '21

3

u/[deleted] 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

u/sunbreakwang Feb 27 '21

Sure. I'll try my best

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:io makes a package platform specific. For dart:html this 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

u/[deleted] Feb 26 '21

[deleted]

1

u/yurabe Feb 26 '21

I'm actually not sure.

1

u/RandalSchwartz Feb 26 '21

dart2js has been around for a long time.