Флаттер - это устройство Ipad в альбомной ориентации? - PullRequest
0 голосов
/ 14 января 2020

Я пытаюсь определить во Flutter, когда подключенным устройством является iPad, и если оно находится в альбомном режиме. До сих пор я выяснил, как определить ориентацию и, если это устройство iOS, но не конкретно, как ориентироваться на все версии iPad. на данный момент телефон от компьютера, но моя цель - быть максимально кратким.

Заранее благодарен за любую помощь!

1 Ответ

1 голос
/ 14 января 2020

Вы можете использовать пакет 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 :)
}
...