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, duration hours minute second in high quality that is uploaded to the channel True Coders 16 February 2024. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 1,158 times and liked it 11 visitors.