Skip to content
Blog

Reading Device Information in Flutter with device_info_plus

device_info_plus 13.3.0 exposes model, OS and hardware details on six platforms — useful for analytics and bug reports if you respect privacy rules.

Published on • November 5, 2026

AI Assistant

Every crash report is more useful with “Moto G (4), Android 13” attached, and every feature flag is safer when it knows the device is a low-RAM emulator rather than a flagship. device_info_plus version 13.3.0, a Flutter Favorite from the verified fluttercommunity.dev publisher, reads that data on Android, iOS, macOS, web, Linux and Windows.

The API surface is tiny — one plugin object, one typed getter per platform — but the details, the cost and the privacy rules decide whether the data helps or hurts you.

DeviceInfoPlugin and the per-platform objects

Import the package, instantiate DeviceInfoPlugin() once, and await the getter for the platform you are on:

import 'package:device_info_plus/device_info_plus.dart';

final deviceInfo = DeviceInfoPlugin();

Future<Map<String, dynamic>> contextForCrashReport() async {
  if (Platform.isAndroid) {
    final AndroidDeviceInfo android = await deviceInfo.androidInfo;
    return {
      'brand': android.brand,              // e.g. "google"
      'model': android.model,              // e.g. "Pixel 8"
      'os': android.version.release,       // e.g. "14"
      'sdk': android.version.sdkInt,       // e.g. 34
      'physical': android.isPhysicalDevice,
    };
  }
  if (Platform.isIOS) {
    final IosDeviceInfo ios = await deviceInfo.iosInfo;
    return {
      'os': ios.systemName,                // "iOS"
      'version': ios.systemVersion,        // "17.5"
      'machine': ios.utsname.machine,      // "iPhone15,4"
      'physical': ios.isPhysicalDevice,
    };
  }
  return {};
}

On web, deviceInfo.webBrowserInfo returns a WebBrowserInfo whose userAgent you can log alongside the session. There is also a generic deviceInfo.deviceInfo getter whose .data map collects everything at once for crash reporting — but the readme warns it is not 100% JSON-serializable, so do not feed it straight into jsonEncode without checking.

What the info objects actually contain

AndroidDeviceInfo is derived from android.os.Build: brand, model, manufacturer, device, isPhysicalDevice, isLowRamDevice, supportedAbis, systemFeatures, physicalRamSize / availableRamSize (megabytes), freeDiskSize / totalDiskSize (bytes), and a nested version (AndroidBuildVersion) with release, sdkInt, securityPatch and baseOS.

IosDeviceInfo comes from UIDevice: systemName, systemVersion, model, modelName (for example iPhone 16 Pro), localizedModel, identifierForVendor, isPhysicalDevice, isiOSAppOnMac, isiOSAppOnVision, plus utsname from sys/utsname.h (machine, nodename, release, sysname, version). Two sharp edges: the name property needs the com.apple.developer.device-information.user-assigned-device-name entitlement on iOS 16+ or it always reads iPad/iPhone, and Android serial numbers return unknown unless the app meets Google’s own Build.getSerial() requirements.

Real uses: analytics, gating and bug reports

The three legitimate patterns are (1) attaching OS and model to crash reports so a bug tied to Android 14 on a specific chipset is reproducible, (2) feature gating — hiding an effect on isLowRamDevice, requiring version.sdkInt >= 26 for a permission flow, or detecting isPhysicalDevice == false to skip expensive on-device ML, and (3) segmentation in analytics, where coarse fields like OS version are far more useful than a device fingerprint.

Cost: it is an async platform channel

Every getter crosses a platform channel to native code, so calling androidInfo inside build() or in a loop pays that round trip repeatedly. Fetch once at startup (or lazily on first use), cache the result in a plain field or a provider, and reuse it; the objects are immutable snapshots, so they are cheap to keep. On web the same rule holds — webBrowserInfo is async too.

Privacy and Play Store policy

Treat this data as personal. Google Play’s Data safety form requires disclosure when device or app information is collected, Apple’s fingerprinting rules restrict combining hardware signals into a stable identifier, and fields like identifierForVendor or a build fingerprint must never be used to track users across apps. Prefer coarse, non-identifying values (OS version, ABI, screen-independent facts), keep them out of URLs and logs that outlive the session, and never present isPhysicalDevice as fraud protection — it is a hint, not a guarantee.

Web, desktop and test doubles

Outside mobile the same plugin returns different types, all visible in the library docs: WebBrowserInfo (derived from navigator, including userAgent and a BrowserName enum) on the web, and WindowsDeviceInfo, LinuxDeviceInfo and MacOsDeviceInfo on the desktop platforms.

Because every getter is async and bound to a platform channel, tests need a seam. Each info object exposes a static setMockInitialValues, so a test can pin the device before the code under test reads it:

testWidgets('skips the heavy effect on simulators', (tester) async {
  IosDeviceInfo.setMockInitialValues(
    name: 'iPhone',
    systemName: 'iOS',
    systemVersion: '17.5',
    model: 'iPhone',
    modelName: 'iPhone 15 Pro',
    localizedModel: 'iPhone',
    identifierForVendor: null,
    isPhysicalDevice: false, // pretend this is a simulator
    isiOSAppOnMac: false,
    isiOSAppOnVision: false,
    physicalRamSize: 8192,
    availableRamSize: 4096,
    freeDiskSize: 64 * 1024 * 1024 * 1024,
    totalDiskSize: 256 * 1024 * 1024 * 1024,
    utsname: IosUtsname.setMockInitialValues(
      sysname: 'Darwin',
      nodename: 'iPhone',
      release: '23.5.0',
      version: 'Darwin Kernel Version 23.5.0',
      machine: 'iPhone16,1',
    ),
  );

  await tester.pumpWidget(const MyApp());
  expect(find.byType(HeavyEffect), findsNothing);
});

Takeaway: device_info_plus is a cheap, well-typed window into OS and hardware facts — cache one async snapshot per launch, use it for crash context and sensible feature gating, and disclose and minimize anything that could identify a user.