Flutter: How to set and lock screen orientation | Lock the entire app or specific screen orientation

Published: 16 February 2024
on channel: True Coders
1,158
11

import 'package:flutter/services.dart';



WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]).then((_) {
runApp(const MyApp());
}
);


or

@override
void initState() {
super.initState();

SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft
]);
}


Watch video Flutter: How to set and lock screen orientation | Lock the entire app or specific screen orientation online without registration, duration hours minute second in high quality. This video was added by user True Coders 16 February 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,158 once and liked it 11 people.