universal_platform
1.1.0, released 2 years ago by gskinner.com
Platform detection across Flutter, Dart web, and desktop without errors
What it does
UniversalPlatform replaces dart.io.Platform to provide safe platform checks on Web, Android, iOS, macOS, Windows, and Linux. It exposes boolean getters like isIOS, isWeb, and desktopOrWeb.
AI-written summary of version 1.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to perform platform checks in your view or model layers
- Your app targets Web and you want to avoid UnsupportedOperation errors
- You want a single API for all supported platforms
Skip it when
- You only target native mobile and can use dart.io.Platform safely
- You need more advanced platform-specific APIs beyond simple checks
Strengths
- No dependencies, lightweight
- Works on all supported platforms including Web
- Simple boolean API
Weaknesses
- Only provides platform checks, no other utilities
- No support for platform-specific APIs beyond booleans
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'package:universal_platform/universal_platform.dart';
bool isIos = UniversalPlatform.isIOS;
bool isWeb = UniversalPlatform.isWeb;Alternatives
Packages that do the same job and could replace universal_platform.
- wasm_ffi
Drop-in replacement for dart:ffi for WebAssembly on the web platform.
68Compare - dbcrypt
A Dart port of jBCrypt for hashing and checking passwords with a configurable work factor.
50Compare - isoweek
Lightweight Dart package providing the Week class based on the ISO 8601 format.
49Compare - launcher_icon_switcher
Dynamically switch app launcher icons on Android and iOS.
40Compare
Works with
Packages commonly used together with universal_platform: ones it builds on, ones built on it, and its own family.
- pdfxBuilt on universal_platformFlutter plugin to render & show PDF pages as images on Web, MacOS, Windows, Android and iOS.
- media_kitBuilt on universal_platformCross‑platform video and audio player for Flutter and Dart
- media_kit_videoBuilt on universal_platformNative implementation for video playback in package:media_kit.
- flutter_nfc_kitBuilt on universal_platformNFC functionality plugin for Android, iOS and Web, supporting NDEF records and APDU transceive.
- device_marketing_namesBuilt on universal_platformLookup device marketing names for Android, iOS and browsers easily.
- video_player_media_kitBuilt on universal_platformpackage:video_player implementation for all platforms powered by package:media_kit.
- just_audio_media_kitBuilt on universal_platformmedia_kit bindings for just_audio to support Linux and Windows.
- kalenderBuilt on universal_platformA customizable calendar widget with day, multi-day, month, and schedule views.