搜尋套件、儲存庫與 APP 分類

套件詳情v5.0.0

platform_info

包含有關目前平台的資訊,例如建構模式和作業系統。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
3.1萬
喜歡數
111
Pub 分數
160

安裝套件

flutter pub add platform_info

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

platform_info 套件提供對目前執行環境詳細資訊的便捷存取,包含建置模式(除錯、發佈、剖析)與作業系統。此套件專為需要根據平台特定特徵條件式執行程式碼的開發者設計。支援所有主要平台:Android、iOS、Web、macOS、Windows 與 Linux,非常適合需要執行時期平台意識的跨平台應用程式。提供輕量級且直覺的 API 來偵測平台細節,無需複雜邏輯或原生程式碼。

適用情境

  • 基於建構模式的條件邏輯
  • 執行時檢測作業系統
  • 跨平台應用程式自訂
  • 執行時期平台診斷
  • 按平台的功能標誌
  • 調試平台特定問題

主要特色

  • 支援所有主要平台
  • 提供建構模式檢測
  • 簡單直覺的 API
  • 輕量且無依賴
  • 即時平台資訊
  • 無需原生程式碼

適合對象

  • 跨平台 Flutter 應用
  • 需要建構模式檢查的應用程式
  • 針對多個作業系統的開發者
  • 測試和除錯場景
  • 具有平台特定功能的應用程式

使用建議

  • 不提供硬體層級的詳細資訊
  • 僅限基本平台與建構資訊
  • 不適用於進階設備檢測
  • 需要手動處理邊緣情況
  • 初始化後無執行時更新
  • 不支援特定裝置型號

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

platform_info

platform_info Checkout Coverage License: MIT Linter GitHub stars

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

Usage

Example of using the library to get the current platform info

Platform Information

Provides platform information such as:

  • Build mode

    • release
    • profile
    • debug
  • Host platform type

    • vm (io, desktops, mobile, console, server)
    • js (web, html, browser)
  • Operating system

    • Fuchsia
    • Linux
    • MacOS
    • Windows
    • iOS
    • Android
    • Unknown
  • Version (unknown if not available)

  • Locale string (en if not available)

  • 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

Sequence of checks
  1. Operating System
  2. Design
  3. Mobile/Desktop
  4. VM/JS
  5. Build mode
  6. Call [orElse] if any callback was not called

Coverage

Changelog

Refer to the Changelog to get all release notes.

Maintainers

Plague Fox

Funding

If you want to support the development of our library, there are several ways you can do it:

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!

License

MIT

Tags

cross, platform, info

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案