platform_detect
2.1.6, released 9 months ago by workiva.com
Detects browser and OS types and versions in Dart web apps.
What it does
Provides runtime detection of the browser and operating system, exposing boolean flags like browser.isChrome or operatingSystem.isMac. It can also add CSS classes to the <html> element for styling based on platform features.
AI-written summary of version 2.1.6, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to adapt UI or behavior based on the user's browser or OS.
- You want to add platform‑specific CSS classes for styling or analytics.
- You need simple feature detection such as touch support.
Skip it when
- You are building a non‑web Flutter app (mobile or desktop).
- You need advanced feature detection beyond touch/mstouch.
Strengths
- Lightweight, no heavy dependencies.
- Simple API with clear boolean flags.
- Can decorate the <html> element for CSS styling.
- Supports custom feature detection via Feature objects.
Weaknesses
- Only works on web; no support for mobile/desktop Flutter.
- Feature detection limited to touch/mstouch unless extended manually.
- No version ranges beyond simple checks.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
Add to pubspec and import package: import 'package:platform_detect/platform_detect.dart';
import 'package:platform_detect/platform_detect.dart';
void main() {
if (browser.isChrome) {
print('Running on Chrome');
}
if (operatingSystem.isMac) {
print('Running on macOS');
}
}Alternatives
Packages that do the same job and could replace platform_detect.
- web_multiple_tab_detector
Detects how many browser tabs your Flutter web app is running in.
64Compare - device_info_plus
Provides detailed information about the current device, make, model, and OS version.
93Compare - android_alarm_manager_plus
Access Android AlarmManager service and run Dart code in the background.
89Compare - device_marketing_names
Lookup device marketing names for Android, iOS and browsers easily.
85Compare
Works with
Packages commonly used together with platform_detect: ones it builds on, ones built on it, and its own family.
- pub_semverplatform_detect depends on itVersions and version constraints implementing pub's versioning policy.
- over_reactBuilt on platform_detectA library for building statically-typed React UI components using Dart.
- flutter_install_app_pluginBuilt on platform_detectInstalls iOS or Android apps from within a Flutter app.