我在我的应用程序中使用振动,因为 iPad 不支持它,所以我想从我的应用程序中删除一个振动设备的按钮。
那么,我如何才能知道我的应用程序是在 iPad 还是 iPhone 上运行呢?
Luc*_*lli 12
device_info的用法是正确的,但是model
应该使用属性:
Future<bool> isIpad() async{
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
IosDeviceInfo info = await deviceInfo.iosInfo;
if (info.model.toLowerCase().contains("ipad")) {
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
小智 1
使用设备信息
Future<bool> isIpad() async{
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
IosDeviceInfo info = await deviceInfo.iosInfo;
if (info.name.toLowerCase().contains("ipad")) {
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3436 次 |
最近记录: |