Package selection guidance compiled from public package information, community data, and project usage.
The platform_info package provides easy access to detailed information about the current execution environment, including the build mode (debug, release, profile) and the operating system. It is designed for developers who need to conditionally execute code based on platform-specific characteristics. The package supports all major platforms: Android, iOS, Web, macOS, Windows, and Linux, making it ideal for cross-platform applications that require runtime platform awareness. It offers a lightweight and straightforward API to detect platform details without requiring complex logic or native code.
Use cases
Conditional logic based on build mode
Detecting operating system at runtime
Cross-platform app customization
Runtime platform diagnostics
Feature flagging by platform
Debugging platform-specific issues
Key features
Supports all major platforms
Provides build mode detection
Simple and intuitive API
Lightweight and dependency-free
Real-time platform info
No native code required
Suitable for
Cross-platform Flutter apps
Apps needing build mode checks
Developers targeting multiple OSes
Testing and debugging scenarios
Apps with platform-specific features
Considerations
Does not provide hardware-level details
Limited to basic platform and build info
Not suitable for advanced device detection
Requires manual handling of edge cases
No runtime updates after initialization
No support for specific device models
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
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!