Home > Software design >  What is the best way to get device information in Flutter?
What is the best way to get device information in Flutter?

Time:09-20

I try to get android Device name.

Now I use package enter image description here

Could you guys recommend the other one that can get that info?

CodePudding user response:

In device_info package after getting the android info, read the values board and product.

Like this:

import 'package:device_info_plus/device_info_plus.dart';

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

CodePudding user response:

dependencies:
  device_information: ^0.0.4

import 'package:device_information/device_information.dart';

try {
      platformVersion = await DeviceInformation.platformVersion;
      imeiNo = await DeviceInformation.deviceIMEINumber;
      modelName = await DeviceInformation.deviceModel;
      manufacturer = await DeviceInformation.deviceManufacturer;
      apiLevel =  await DeviceInformation.apiLevel;
      deviceName = await DeviceInformation.deviceName;
      productName = await DeviceInformation.productName;
      cpuType = await DeviceInformation.cpuName;
      hardware = await DeviceInformation.hardware;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
  • Related