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)

Usage

import 'package:platform_plus/platform_plus.dart';

void example() async {
  if (platformPlus.isAndroidNative) {
    // Do something
  } else if (platformPlus.isAndroidWeb) {
    // Do something else
  }

  if (await platformPlus.isPhysicalDevice) {
    // Do something
  }

  if (platformPlus.isUnitTest) {
    // Do something
  }

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

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

  final iosDevice = await platformPlus.iosDevice;
  if (iosDevice == IOSDevice.iPhone) {
    // Do something
  }
}

Libraries

platform_plus