How to enable landscape and portrait orientation to tablets and iPad, but small devices just portrait mode?
Set orientations
void main() async {
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(
// ..
);
}
2
Answers
You can set the desired orientation for your Flutter app by using the SystemChrome.setPreferredOrientations method. To enable landscape and portrait orientation for tablets and iPads, but only portrait mode for smaller devices, you can use the following code:
In this code, Platform.isTablet and Platform.isIOS are used to determine whether the device is a tablet or an iPad. If the device is a tablet or an iPad, the SystemChrome.setPreferredOrientations method is called with an array of DeviceOrientation values that allow both landscape and portrait orientations. If the device is not a tablet or an iPad, the method is called with an array of DeviceOrientation values that allow only portrait orientation.
Another approach is to check the width of device.
Use MediaQuery or WidgetsBinding intance (see here)
From research, you can find the widest phone dimension(lets say 480px)
and add it as a breakpoint. check manually all devices or use the breakpoints mentioned in this article for html
your condition could be as follows: