universal_platform 1.1.0 copy "universal_platform: ^1.1.0" to clipboard
universal_platform: ^1.1.0 copied to clipboard

Replacement for dart.io.Platform class which works on Web as well as Desktop and Mobile. Allows platform checks in your view/model layer easily.

Universal Platform - A Web-safe Platform class #

pub package

Currently, if you include the dart.io.Platform anywhere in your code, your app will throw the following error on Web:

Unsupported operation: Platform._operatingSystem
copied to clipboard

With this plugin you can perform platform detection on all platforms, including Web, without errors.

🔨 Installation #

dependencies:
  universal_platform: ^1.0.0+1
copied to clipboard

⚙ Import #

Remove any usages of dart.io.Platform, and replace with this:

import 'package:universal_platform/universal_platform.dart';
copied to clipboard

🕹ī¸ Usage #

This acts as a drop-in replacement for dart.io.Platform, with a different name for improved clarity.

//This will explode on Web
bool isIos = Platform.isIOS;

//This will not :)
bool isIos = UniversalPlatform.isIOS;
bool isWeb = UniversalPlatform.isWeb;
copied to clipboard

🐞 Bugs/Requests #

If you encounter any problems feel open an issue. If you feel the library is missing a feature, please raise a ticket on Github and we'll look into it. Pull request are also welcome.

📃 License #

MIT License

301
likes
140
points
751k
downloads

Publisher

verified publishergskinner.com

Weekly Downloads

2024.09.13 - 2025.03.28

Replacement for dart.io.Platform class which works on Web as well as Desktop and Mobile. Allows platform checks in your view/model layer easily.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

More

Packages that depend on universal_platform