platform_plus
4.8.5, released 6 months ago by rexios.dev
Easily figure out detailed information about the platform your code is running on.
What it does
Platform Plus helps you detect specific platforms, operating system versions, web renderers, and device states such as whether the app runs on a physical device or in a unit test. It initializes asynchronously so that subsequent platform checks can be made synchronously.
AI-written summary of version 4.8.5, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to execute different logic for native versus web environments across various operating systems.
- You need to check specific OS versions, web renderers, or if the app is running on a physical device.
- You need to detect if your code is currently running within a unit test.
Skip it when
- You only need standard Flutter web checks which can be handled using Flutter's built-in kIsWeb.
Strengths
- Comprehensive properties covering native vs web distinctions for major platforms.
- Provides helpful device details like physical device detection, Android SDK versions, and iOS device types.
- Supports web platform including web renderers and WASM.
Weaknesses
- Requires an asynchronous initialization step before calling platform property checks.
- Fuchsia web support is currently unsupported.
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 3
Call PlatformPlus.platform.init() before accessing platform properties.
import 'package:platform_plus/platform_plus.dart';
void example() async {
await PlatformPlus.platform.init();
if (PlatformPlus.platform.isAndroidNative) {
// Do something
}
final androidVersionCode = PlatformPlus.platform.androidVersionCode;
if ((androidVersionCode ?? -1) >= AndroidVersionCode.s) {
// Do something
}
}Alternatives
Packages that do the same job and could replace platform_plus.
- universal_platform
If you want a lightweight package specifically for checking platform types across web and native without additional device info or initialization requirements.
50Compare
Works with
Packages commonly used together with platform_plus: ones it builds on, ones built on it, and its own family.
- webplatform_plus depends on itLightweight bindings for browser APIs via JS interop
- package_info_plusplatform_plus depends on itFlutter plugin to query app package info like version, build number and installer store.
- device_info_plusplatform_plus depends on itProvides detailed information about the current device, make, model, and OS version.