Flutter: how to prevent device orientation changes and force portrait?
Import package:flutter/services.dart, then Put the SystemChrome.setPreferredOrientations inside the Widget build() method. Example: class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); return new MaterialApp(…); } } Update This solution mightn’t work for some IOS devices as mentioned in the updated flutter documentation on Oct 2019. They Advise to fixed the … Read more