Skip to content
pubscout

platform_detect

2.1.6, released 9 months ago by workiva.com

Detects browser and OS types and versions in Dart web apps.

$ flutter pub add platform_detect
Source repository

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.

Works with

Packages commonly used together with platform_detect: ones it builds on, ones built on it, and its own family.