Conditional package import for desktop in Flutter

Viewed 1535

I know that the availability of dart.library.html can be used as the condition for web, but what about desktop?

Although I suppose you can import a particular package for desktop and not for mobile if you create and use a new package in which different packages are specified for different platforms in pubspec.yaml as explained in the document, it seems a little redundant to make such a package for that purpose.

Is it possible just by using a statement of the import 'foo.dart' if (...) 'bar.dart' style, and if possible, what library is put in its if (...) part?

1 Answers

You cannot use conditional imports to get different behavior between mobile and desktop; see this comment from the Dart team.

Related