isMobileView function

bool isMobileView(
  1. BuildContext context
)

Implementation

bool isMobileView(BuildContext context) {
  var longestSide = MediaQuery.of(context).size.longestSide;
  String breakpoint = "1024";
  final bool isMobileMediaQuery = longestSide < int.parse(breakpoint);
  bool isIOSAndroid = !kIsWeb && (Platform.isIOS || Platform.isAndroid);

  if (isMobileMediaQuery == true && isIOSAndroid == true) {
    SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
  } else {
    SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
  }

  return isMobileMediaQuery;
}