如何隐藏旋转设备方向的变化?
How hide rotate device orientation changes on flutter?
如何在 flutter 上隐藏旋转设备方向的变化?
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
return MaterialApp(...);
}
}
//Use this inside main() of main.dart
//make sure that you have an instance of the WidgetsBinding.
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp],
); // To set your device orientation throughout the App.
如何在 flutter 上隐藏旋转设备方向的变化?
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
return MaterialApp(...);
}
}
//Use this inside main() of main.dart
//make sure that you have an instance of the WidgetsBinding.
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp],
); // To set your device orientation throughout the App.