getDeviceModel static method

Future<String> getDeviceModel()

获取设备型号 返回如 "iPhone 12, Pixel 5, Huawei P40" 这样的字符串

Implementation

static Future<String> getDeviceModel() async {
  try {
    if (Platform.isAndroid) {
      final androidInfo = await deviceInfoPlugin.androidInfo;
      return androidInfo.model;
    } else if (Platform.isIOS) {
      final iosInfo = await deviceInfoPlugin.iosInfo;
      return iosInfo.utsname.machine;
    } else {
      return 'Unknown Device';
    }
  } catch (e, stackTrace) {
    StormyLog.e(
      'AppUtils.getDeviceModel: 获取设备型号失败',
      stackTrace: stackTrace,
      extra: {'error': e.toString()},
    );
    return 'Unknown Device';
  }
}