flutter插件device_info


从Flutter应用程序中获取当前设备信息。

添加依赖

dependencies:
  device_info: ^0.4.0+1

安装

flutter packages get

实例

导入包:device_info / device_info.dart,实例化DeviceInfoPlugin并使用Android和iOS getter获取特定于平台的设备信息。

import 'package:device_info/device_info.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"