platform_info 패키지는 빌드 모드(디버그, 릴리스, 프로파일) 및 운영 체제를 포함하여 현재 실행 환경에 대한 세부 정보에 쉽게 접근할 수 있도록 제공합니다. 이 패키지는 플랫폼 고유의 특성에 따라 코드를 조건부로 실행해야 하는 개발자를 위한 것입니다. Android, iOS, Web, macOS, Windows, Linux 등 모든 주요 플랫폼을 지원하므로 런타임 시 플랫폼 인식이 필요한 크로스플랫폼 애플리케이션에 적합합니다. 복잡한 논리나 네이티브 코드 없이도 플랫폼 세부 정보를 감지할 수 있는 가볍고 간단한 API를 제공합니다.
사용 사례
빌드 모드에 기반한 조건 논리
런타임 시 운영 체제 감지
크로스 플랫폼 앱 사용자 정의
런타임 플랫폼 진단
플랫폼별 기능 플래깅
플랫폼별 문제 디버깅
주요 기능
모든 주요 플랫폼을 지원합니다
빌드 모드 감지를 제공합니다
간단하고 직관적인 API
경량이며 종속성 없음
실시간 플랫폼 정보
네이티브 코드가 필요하지 않습니다
적합한 대상
크로스 플랫폼 플러터 앱
빌드 모드 확인이 필요한 앱
다수의 OS를 대상으로 하는 개발자
테스트 및 디버깅 시나리오
플랫폼별 기능을 갖춘 앱
고려 사항
하드웨어 수준의 세부 정보를 제공하지 않습니다
기본 플랫폼 및 빌드 정보에 한정
고급 장치 탐지에 적합하지 않습니다
경계 사례에 대한 수동 처리가 필요합니다
초기화 후 런타임 업데이트 없음
특정 기기 모델에 대한 지원 없음
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
platform_info
About
Cross-platform io/html package.
Works on the web, mobile phones, desktops and console.
Fully caches itself on first initialization.
Easy to use, just add to pubspec.yaml as dependency and then import:
import 'package:platform_info/platform_info.dart';
Platform is a singleton, and the default way to access an instance of Platform is to call static getters:
Platform.instance or Platform.I or platform
The number of individual execution units of the machine (0 if not available)
Operating system is a known type
Is a Web-based applications
Is a VM supporting for non-web applications
Is a mobile device (Android, iOS)
Is a desktop device (Windows, macOS, Fuchsia)
Is Material design device (Android, Fuchsia)
Is Cupertino design device (macOS, iOS)
is Linux
is macOS
is Windows
is android
is iOS
is fuchsia
when method allowing to compose a complex condition
Pattern matching
Run functions that satisfy the current state of the platform.
You can use nested methods to compose more complex queries.
Operating System
[fuchsia] - whether the operating system is a version of Fuchsia
[windows] - whether the operating system is a version of Windows
[android] - whether the operating system is a version of Android
[iOS] - whether the operating system is a version of iOS
[macOS] - whether the operating system is a version of MacOS
[linux] - whether the operating system is a version of Linux
[unknown] - operating system unknown
Design
[material] - is material (Android, Fuchsia)
[cupertino] - is cupertino (macOS, iOS)
Mobile or desktop
[mobile] - is mobile device (Android, iOS)
[desktop] - is desktop device (Windows, MacOS, Fuchsia)
VM (IO) or JS (Web)
[js] - is web-based applications
[vm] - is I/O supporting for non-web applications
Build mode
[release] - release build mode
[profile] - profile build mode
[debug] - debug build mode
[orElse] - any callback was not called
We appreciate any form of support, whether it's a financial donation or just a star on GitHub. It helps us to continue developing and improving our library. Thank you for your support!