universal_platform
dart:io.Platform क्लास का प्रतिस्थापन जो वेब, डेस्कटॉप और मोबाइल पर काम करता है। आपको अपने दृश्य/मॉडल परत में प्लेटफॉर्म चेक आसानी से करने देता है।
dart.io.Platform का वेब-सुरक्षित कार्यान्वयन। "Unsupported operation: Platform._operatingSystem" रनटाइम त्रुटि से बचने में मदद करता है।
यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।
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
With this plugin you can perform platform detection on all platforms, including Web, without errors.
dependencies:
universal_platform: ^1.0.0+1
Remove any usages of dart.io.Platform, and replace with this:
import 'package:universal_platform/universal_platform.dart';
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;
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.
MIT License