how to get display orientation in flutter code example
Example 1: flutter set orientation
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
.then((value) => runApp(MyApp()));
}
Example 2: flutter display widget based on device orientation
build(BuildContext context) {
final isLandscape = MediaQuery.of(context).orientation ==
Orientation.landscape;
if (!isLandscape) txListWidget,
if (isLandscape)
_ternaryCondition ? _showFirstWidget : _showSecondWidget
}