I would like to enable my application screen to landscape or portrait only for tablets. Still on Portrait for smartphone The application was developed by Flutter.
I would like to enable my application screen to landscape or portrait only for tablets. Still on Portrait for smartphone The application was developed by Flutter.
check device is tablet
class DeviceUtil {
static String get _getDeviceType {
final data = MediaQueryData.fromWindow(WidgetsBinding.instance.window);
return data.size.shortestSide < 550 ? 'phone' : 'tablet';
}
static bool get isTablet {
return _getDeviceType == 'tablet';
}
}
DeviceUtil.isTablet; //true
use of this
if(DeviceUtil.isTablet){
//landscape-or-potrait
}else{
//landscape-or-potrait
}
You can set portrait with SystemChrome
final data = MediaQueryData.fromWindow(WidgetsBinding.instance!.window);
if(data.size.shortestSide > 600) { // check if its bigger
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
} else { // otherwise will be ..
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
}
Play with digit to get the best