main function
"Set the preferred orientation of the app to landscape, then run the app."
The first line of the function is a call to WidgetsFlutterBinding.ensureInitialized(). This is a function that is called automatically when the app starts, but it's a good idea to call it explicitly in main() to make sure that the app is initialized before we try to set the preferred orientation
Implementation
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setEnabledSystemUIMode(
SystemUiMode.manual,
overlays: <SystemUiOverlay>[
SystemUiOverlay.bottom, //This line is used for showing the bottom bar
],
);
SystemChrome.setPreferredOrientations(<DeviceOrientation>[
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]).then((void value) => runApp(const MyApp()));
}