搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目