Skip to content

kumsumit/device_info_plus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

device_info_plus

pub package pub points device_info_plus

Get current device information from within the Flutter application.

Platform Support

Android iOS MacOS Web Linux Windows

Requirements

  • Flutter >=3.22.0
  • Dart >=3.4.0 <4.0.0
  • iOS >=12.0
  • MacOS >=10.14
  • Android compileSDK 34
  • Java 17
  • Android Gradle Plugin >=8.3.0
  • Gradle wrapper >=8.4

Usage

Import package:device_info_plus/device_info_plus.dart, instantiate DeviceInfoPlugin and use the Android and iOS, Web getters to get platform-specific device information.

Example:

import 'package:device_info_plus/device_info_plus.dart';

DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
print('Running on ${androidInfo.model}');  // e.g. "Moto G (4)"

IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
print('Running on ${iosInfo.utsname.machine}');  // e.g. "iPod7,1"

WebBrowserInfo webBrowserInfo = await deviceInfo.webBrowserInfo;
print('Running on ${webBrowserInfo.userAgent}');  // e.g. "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0"

The plugin provides a data method that returns platform-specific device information in a generic way, which can be used for crash-reporting purposes.

However, the data provided by this data method is currently not serializable (i.e. it is not 100% JSON compatible) and shouldn't be treated as such.

import 'package:device_info_plus/device_info_plus.dart';

final deviceInfoPlugin = DeviceInfoPlugin();
final deviceInfo = await deviceInfoPlugin.deviceInfo;
final allInfo = deviceInfo.data;

Android

To get serial number on Android your app needs to meet one of official requirements. In case the app doesn't meet any of requirements plugin will return unknown.

iOS

The name property exposes the assigned device name by the owner. This value is obtained from the property UIDevice.current.name. This property requires special entitlement com.apple.developer.device-information.user-assigned-device-name in iOS 16 and later, otherwise, the property name will always be iPad or iPhone.

Learn more

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors