FLUTTER ECOSYSTEM

universal_platform

Replacement for dart.io.Platform class which works on Web as well as Desktop and Mobile. Allows platform checks in your view/model layer easily.

Latest version
1.1.0
30-day downloads
1.5M
Likes
313
Pub points
150

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Overview

The universal_platform package provides a cross-platform replacement for Dart's Platform class, enabling consistent platform detection across Web, mobile, and desktop environments. It allows developers to perform platform checks in business logic layers (like views and models) without relying on platform-specific implementations. This ensures reliable behavior regardless of the target runtime, simplifying code that needs to adapt based on the underlying platform.

Use cases
  • Cross-platform app development
  • Platform-specific UI/behavior logic
  • Shared business logic across platforms
  • Testing on multiple targets
  • Avoiding platform-specific imports
Key features
  • Unified platform detection
  • Works on Web, Android, iOS, macOS, Windows, Linux
  • No need for conditional imports
  • Simple API similar to dart:io.Platform
  • Supports isAndroid, isIOS, isWeb, etc.
Suitable for
  • Developers targeting multiple platforms
  • Apps requiring consistent platform checks
  • Teams avoiding platform-specific code duplication
  • Projects using shared logic across platforms
  • Those needing reliable web support
Considerations
  • Requires explicit import instead of dart:io.Platform
  • May not cover all niche platform features
  • Limited to basic platform identification
  • Not a full replacement for all dart:io functionality
  • Depends on external dependency management
Supported platformsAndroidiOSWebmacOSWindowsLinux

Install package

flutter pub add universal_platform

Categories

Source repository

Related projects