Trending Articles       10 Flutter Listview Examples       Flutter Custom Button Example       Flutter Audio Recording       Flutter 2.0 Autocomplete TextField       Current Location Google Maps

Flutter Device Info | Read Device Info on Android and iOS devices with device_info plugin

Different types of Mobile devices are available in the market and we don't know on which device our mobile app is running.

To know about complete device info in flutter we have a library called device_info. with this plugin, we can read complete device info inside our application.

device_info plugin will give complete device information on platform specific.

To work with this library first we need to add the library in pubspec.yaml file.

The current version of the library is 1.0.0

device_info 1.0.0


To use this library in our widget class we need to import by adding below line

import 'package:device_info/device_info.dart';


Then we need to create an instance for DeviceInfoPlugin, which will return platform-specific information.

DeviceInfoPlugin deviceInfo = new DeviceInfoPlugin();


Get Android Specific device info

DeviceInfoPlugin deviceInfo = new DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
print('Running on ${androidInfo.model}');


This will print the android device model


 Get Android Specific device info

DeviceInfoPlugin deviceInfo = new DeviceInfoPlugin();

IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
print('Running on ${iosInfo.utsname.machine}');


In this example, we are using the FutureBuilder to get the device info from the DeviceInfoPlugin class.


  builder: (context,snapshaot){;


The snapshot object will contain all device information


Complete example

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:device_info/device_info.dart';
import 'package:flutter/services.dart';
class DeviceINfo extends StatelessWidget{
  static final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
  Map _deviceData = {};
  Widget build(BuildContext context) {
    // TODO: implement build
   return MaterialApp(
     home: Scaffold(
       appBar: AppBar(title: Text("Device Info"),),
       body: FutureBuilder(
         builder: (context,snapshaot){
               return Center(child: Text("Not able to find device info"),);
           return ListView(
               children: property) {
             return Row(
               children: [
                   padding: const EdgeInsets.all(10.0),
                   child: Text(
                     style: const TextStyle(
                       fontWeight: FontWeight.bold,
                       color: Colors.deepOrange
                     child: Container(
                       padding: const EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 10.0),
                       child: Text(
                         maxLines: 10,
                         overflow: TextOverflow.ellipsis,

  Future> initPlatformState() async {
    Map deviceData;

    try {
      if (Platform.isAndroid) {
        deviceData = _readAndroidBuildData(await deviceInfoPlugin.androidInfo);
      } else if (Platform.isIOS) {
        deviceData = _readIosDeviceInfo(await deviceInfoPlugin.iosInfo);
    } on PlatformException {
      deviceData = {
        'Error:': 'Failed to get platform version.'
return deviceData;


  Map _readAndroidBuildData(AndroidDeviceInfo build) {
    return {
      'version.securityPatch': build.version.securityPatch,
      'version.sdkInt': build.version.sdkInt,
      'version.release': build.version.release,
      'version.previewSdkInt': build.version.previewSdkInt,
      'version.incremental': build.version.incremental,
      'version.codename': build.version.codename,
      'version.baseOS': build.version.baseOS,
      'board': build.board,
      'bootloader': build.bootloader,
      'brand': build.brand,
      'device': build.device,
      'display': build.display,
      'fingerprint': build.fingerprint,
      'hardware': build.hardware,
      'manufacturer': build.manufacturer,
      'model': build.model,
      'product': build.product,
      'supported32BitAbis': build.supported32BitAbis,
      'supported64BitAbis': build.supported64BitAbis,
      'supportedAbis': build.supportedAbis,
      'tags': build.tags,
      'type': build.type,
      'isPhysicalDevice': build.isPhysicalDevice,
      'androidId': build.androidId,
      'systemFeatures': build.systemFeatures,

  Map _readIosDeviceInfo(IosDeviceInfo data) {
    return {
      'systemName': data.systemName,
      'systemVersion': data.systemVersion,
      'model': data.model,
      'localizedModel': data.localizedModel,
      'identifierForVendor': data.identifierForVendor,
      'isPhysicalDevice': data.isPhysicalDevice,
      'utsname.sysname:': data.utsname.sysname,
      'utsname.nodename:': data.utsname.nodename,
      'utsname.release:': data.utsname.release,
      'utsname.version:': data.utsname.version,
      'utsname.machine:': data.utsname.machine,


Read about User Login & Registration with PHP Rest API




Author: RRTutors

Flutter Questions

Android Questions