Skip to content
pubscout

platform_detector

0.2.0, released 3 years ago by ea2.dev

Detects the running platform, browser type, and operating system with utility widgets.

$ flutter pub add platform_detector
Source repository

What it does

Identifies the platform (web, mobile, desktop, mobile browser, desktop browser) on which a Flutter application is running. Provides utility methods, conditional check functions, and widgets to render platform-specific UI.

AI-written summary of version 0.2.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to conditionally render different UI components based on whether the app runs on a mobile device, web, or desktop.
  • You need to detect browser-specific environments like Web Android or Web iOS.

Skip it when

  • You only need standard Flutter platform checks available out of the box via targetPlatform.
  • You are writing non-Flutter Dart code.

Strengths

  • Provides fine-grained detection including mobile vs desktop browsers.
  • Includes helpful widgets like PlatformDetectByType and PlatformDetectByName for declarative rendering.

Weaknesses

  • Relies on universal_html which might add unnecessary dependencies if web browser detection is not needed.
  • Duplicates functionality that can be achieved via Flutter's core libraries and universal_platform.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1

Add the dependency to pubspec.yaml and import the library.

final PlatformType currentPlatformType = PlatformDetector.platform.type;

PlatformDetectByType(
  web: YourWebWidget(),
  mobile: YourMobileWidget(),
  desktop: YourDesktopWidget(),
);

Alternatives

Packages that do the same job and could replace platform_detector.

  • universal_platform

    If you just need standard platform detection across web and native platforms without extra UI widgets.

Works with

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