Skip to content

Latest commit

 

History

History
65 lines (44 loc) · 2.64 KB

File metadata and controls

65 lines (44 loc) · 2.64 KB

The UniversalPlatform Package

Did you know?

If your code checks the current platform with Platform.isIOS, you’ll get a runtime exception when you run on Flutter web. 💥

As an alternative, you can use the Universal Platform package, which works on all platforms and offers a unified syntax.


Note that the UniversalPlatform class has two drawbacks:

  • It doesn't (yet) support tree-shaking of the conditional code (see issue #29 for details)
  • The platform can't be overridden during testing (see issue #15 for details)

If you don't want to rely on a 3rd party package to perform platform checks, see my next tip about defaultTargetPlatform and kIsWeb.


Previous Next
Taking screenshots with the Flutter CLI Use defaultTargetPlatform and kIsWeb