talira

platform

A pluggable, mockable platform information abstraction for Dart

open sourceBSD-3-Clausefree

platform is a Dart package from the Dart team that gives cross-platform access to information about the current runtime. On native platforms its NativePlatform wraps the static Platform properties of dart:io, and on the web it exposes a BrowserPlatform with the browser's user agent, so the same code can check which one it runs on. Its testing library mocks platform objects and overrides the current platform in tests, and platform checks used as branch conditions let a production compiler drop code for other platforms.

Problems it solves

  • check which operating system my Dart program is running on
  • mock the platform in Dart tests
  • write Dart code that runs on both native and the web and knows which one it is on

Features

  • Cross-platform Platform API for native and web
  • NativePlatform wrapper over dart:io Platform properties
  • BrowserPlatform with the user agent on the web
  • Mock platforms and Zone-based overrides for tests