platform_plus 4.8.3

SDKflutter
Platformandroidioswindowslinuxmacosweb

Platform Plus is a package for easily figuring out information about the platform your code is running on

Platform Plus is a package for easily figuring out information about the platform your code is running on

Features

PropertyUse-case
isAndroidNativeAndroid native
isAndroidWebAndroid browser
isIOSNativeiOS native
isIOSWebiOS browser
isWindowsNativeWindows native
isWindowsWebWindows browser
isMacOSNativemacOS native
isMacOSWebmacOS browser
isLinuxNativeLinux native
isLinuxWebLinux browser
isFuschiaNativeFuschia native
isFuschiaWebFuschia browser (currently unsupported)
supportsFirebaseWeb or Android native or iOS native or macOS native
isUnitTestRunning with flutter test
isPhysicalDeviceRunning on a physical device (not an emulator)
androidVersionCodeAndroid SDK version (see AndroidVersionCode)
iosVersioniOS version
iosDeviceThe iOS device (see IOSDevice)
isTestFlightIf the app was installed from TestFlight
webRendererThe current web renderer

Usage

import 'package:platform_plus/platform_plus.dart';

void example() async {
  await PlatformPlus.platform.init();

  if (PlatformPlus.platform.isAndroidNative) {
    // Do something
  } else if (PlatformPlus.platform.isAndroidWeb) {
    // Do something else
  }

  if (PlatformPlus.platform.isPhysicalDevice) {
    // Do something
  }

  if (PlatformPlus.platform.isUnitTest) {
    // Do something
  }

  final androidVersionCode = PlatformPlus.platform.androidVersionCode;
  if ((androidVersionCode ?? -1) >= AndroidVersionCode.s) {
    // Do something
  }

  final iosVersion = PlatformPlus.platform.iosVersion;
  if ((iosVersion ?? -1) >= 13) {
    // Do something
  }

  final iosDevice = PlatformPlus.platform.iosDevice;
  if (iosDevice == IOSDevice.iPhone) {
    // Do something
  }

  final webRenderer = PlatformPlus.platform.webRenderer;
  if (webRenderer == WebRenderer.wasm) {
    // Do something
  }
}