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

outdated

Replacement for dart.io.Platform class which works on Web as well as Desktop and Mobile.

Universal Platform - A Web-safe Platform class #

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

Unsupported operation: Platform._operatingSystem

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

🔨 Installation #

dependencies:
  universal_platform: ^0.1.0

⚙ Import #

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

import 'package:universal_platform/universal_platform.dart';

🕹ī¸ 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;

🐞 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

290
likes
0
pub points
98%
popularity

Publisher

verified publishergskinner.com

Replacement for dart.io.Platform class which works on Web as well as Desktop and Mobile.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on universal_platform