cross_platform
3.1.0, released 9 months ago by thisismarch.dev
Unified API for detecting the current platform and basic system info across Flutter, web, and desktop.
WASM-ready
What it does
Wraps dart:io and dart:html Platform APIs into a single interface. Offers getters like isWeb, isAndroid, isDesktop and basic properties such as numberOfProcessors and operatingSystemVersion.
AI-written summary of version 3.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need simple platform checks to branch code for web, mobile, or desktop.
- You want a single import to access common Platform properties on all supported targets.
Skip it when
- You require detailed device information beyond basic OS detection.
- You need advanced features like hardware sensors or permissions.
Strengths
- Single unified API for all Flutter targets
- Covers all major platforms (android, iOS, web, windows, macOS, linux)
- Zero native setup or permissions
Weaknesses
- Only provides basic platform info, no deep device details
- Duplicates functionality already available in dart:io/dart:html
- Limited to the features listed in the README
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
import 'package:cross_platform/cross_platform.dart';
void main() {
if (Platform.isWeb) {
print('Running on the web');
} else if (Platform.isMobile) {
print('Running on a mobile device');
}
print('OS: ${Platform.operatingSystem}');
}Alternatives
Packages that do the same job and could replace cross_platform.
- universal_platform
Offers similar cross‑platform detection with a lightweight implementation.
50Compare
Works with
Packages commonly used together with cross_platform: ones it builds on, ones built on it, and its own family.
- webcross_platform depends on itLightweight bindings for browser APIs via JS interop
- cross_connectivitySame familyFlutter plugin to monitor real network connectivity across mobile, web, and desktop.
- cross_local_storageSame familySharedPreferences wrapper for Mobile, Web, and Desktop with JSON file storage support.