getDeviceId static method

Future<String?> getDeviceId()

获取设备唯一标识符(需要在AndroidManifest.xml或Info.plist中添加权限)。

Implementation

static Future<String?> getDeviceId() async {
  try {
    return await const MethodChannel('device_utils')
        .invokeMethod('getDeviceId');
  } on PlatformException catch (e) {
    debugPrint("Failed to get device id: '${e.message}'.");
    return null;
  }
}