device_infoをつかってみる[Flutter]

YouTube

動画版はこちら。

Example of device_info

flutterのpluginsリポジトリにdevice_infoがあります。
その中にexampleがあります。
そのexampleを参考にすれば使い方がわかります。

https://github.com/flutter/plugins/tree/master/packages/device_info/device_info/example

プロパティと対応する出力例

コメント部分は出力例。

  // Comments are example.
  Map<String, dynamic> _readAndroidBuildData(AndroidDeviceInfo build) {
    return <String, dynamic>{
      'version.securityPatch': build.version.securityPatch, // 2020-09-05
      'version.sdkInt': build.version.sdkInt, // 30
      'version.release': build.version.release, // 11
      'version.previewSdkInt': build.version.previewSdkInt, // 0
      'version.incremental': build.version.incremental, // 6903271
      'version.codename': build.version.codename, // REL
      'version.baseOS': build.version.baseOS, // 
      'board': build.board, // goldfish_x86
      'bootloader': build.bootloader, //unknown
      'brand': build.brand, // google
      'device': build.device, // generic_x86_arm
      'display': build.display, // sdk_gphone_x86_arm-userdebug 11 RSR1.201013.001 6903271 dev-keys
      'fingerprint': build.fingerprint, // google/sdk_gphone_x86_arm/generic_x86_arm:11/RSR1.201013.001/6903271:userdebug/dev-keys
      'hardware': build.hardware, // ranchu
      'host': build.host, // abfarm-us-west1-c-0007
      'id': build.id, // RSR1.201013.001
      'manufacturer': build.manufacturer, // Google
      'model': build.model, // sdk_gphone_x86_arm
      'product': build.product, // sdk_gphone_x86_arm
      'supported32BitAbis': build.supported32BitAbis, // [x86, armeabi-v7a, armeabi]
      'supported64BitAbis': build.supported64BitAbis, // []
      'supportedAbis': build.supportedAbis, // [x86, armeabi-v7a, armeabi]
      'tags': build.tags, // dev-keys
      'type': build.type, // userdebug
      'isPhysicalDevice': build.isPhysicalDevice, // false
      'androidId': build.androidId,
      'systemFeatures': build.systemFeatures,
    };
  }

  Map<String, dynamic> _readIosDeviceInfo(IosDeviceInfo data) {
    return <String, dynamic>{
      'name': data.name,  // iPhone 12 Pro Max
      'systemName': data.systemName,  // iOS
      'systemVersion': data.systemVersion,  // 14.3
      'model': data.model,  // iPhone
      'localizedModel': data.localizedModel,  // iPhone
      'identifierForVendor': data.identifierForVendor,  // CD0C5C59-A3E7-499E-BD1E-3E0A3B900D32
      'isPhysicalDevice': data.isPhysicalDevice,  // false
      'utsname.sysname:': data.utsname.sysname, // Darwin
      'utsname.nodename:': data.utsname.nodename, // MacBook-Pro.local
      'utsname.release:': data.utsname.release, // 20.1.0
      'utsname.version:': data.utsname.version, // Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64
      'utsname.machine:': data.utsname.machine, // x86_64
    };
  }

スポンサーリンク