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