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

View all comments

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

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.