platform_info
5.0.0, released 2 years ago by plugfox.dev
Provides cross-platform information about build modes, operating systems, and device types.
What it does
Retrieves and caches current platform details such as OS, build mode (debug, profile, release), locale, and execution units. It also provides pattern matching and boolean checks for targeting specific platforms and design systems.
AI-written summary of version 5.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to conditionally execute code based on whether the app runs on Android, iOS, Web, or desktop.
- You want to check the current build mode (debug, release, profile).
- You need a singleton helper to query host platform type (VM or JS) and device form factor.
Skip it when
- You only need basic conditional checks already covered by Flutter's standard kIsWeb or Platform APIs without extra packages.
Strengths
- Fully caches platform information on first initialization.
- Supports a wide range of platforms including Android, iOS, web, Windows, macOS, and Linux.
- Provides a convenient pattern matching `when` method for complex condition composition.
Weaknesses
- Relies on a global singleton pattern which might not fit all architectural styles.
- Limited to platform flags and static information.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
import 'package:platform_info/platform_info.dart';
void main() {
final platform = Platform.instance;
if (platform.isAndroid) {
// Android specific code
}
}Alternatives
Packages that do the same job and could replace platform_info.
- package_info_plus
Flutter plugin to query app package info like version, build number and installer store.
93Compare - location
Flutter plugin to get real-time device location across platforms.
94Compare - device_info_plus
Provides detailed information about the current device, make, model, and OS version.
93Compare - system_info2
Provides easy access to system information like architecture, kernel, memory, OS, CPU, and user.
85Compare
Works with
Packages commonly used together with platform_info: ones it builds on, ones built on it, and its own family.