Flutter - 设备在 Landscape 中是 Ipad 吗?

Flutter - Is the device an Ipad in Landscape?

我试图在 Flutter 中识别连接的设备是 iPad 以及它是否处于横向模式。到目前为止,我已经弄清楚如何确定方向以及它是否是 iOS 设备 - 但不是具体如何定位 iPad.

的所有版本

此时我愿意满足于能够从计算机上识别 phone 平板电脑 - 但我的目标是尽可能简洁。

在此先感谢您的帮助!

您可以使用包 https://pub.dev/packages/flutter_device_type

代码片段

//Get the physical device size
print( Device.size );
//Quick methods to access the physical device width and height
print("Device Width: ${Device.width}, Device Height: ${Device.height}");

//To get the actual screen size (Which is same as what MediaQuery gives)
print( Device.screenSize );
//Quick methods to access the screen width and height
print("Device Width: ${Device.screenWidth}, Device Height: ${Device.screenHeight}");

//Check if device is tablet
if( Device.get().isTablet ){
    //do something large
}

//Check if device is iphone x
if( Device.get().isIphoneX ){
    //Do some notch business
}

//Other utility methods
print( Device.get().isPhone );
print( Device.get().isAndroid );
print( Device.get().isIos );

//So to check for iPad for instance
if( Device.get().isIos && Device.get().isTablet ){
    //make the font larger :)
}