Last active
October 26, 2020 05:20
-
-
Save ryohtarot/e34b7c17b207e527d9dcfb1f0e9d6ba0 to your computer and use it in GitHub Desktop.
【Flutter】画面を縦/横に固定する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter/services.dart'; // 追加 | |
// 画面を縦に固定する場合 | |
void main() { | |
SystemChrome.setPreferredOrientations([ | |
DeviceOrientation.portraitUp, | |
DeviceOrientation.portraitDown, | |
]).then((_) { | |
runApp(new MyApp()); | |
}); | |
} | |
// 画面を横に固定する場合 | |
void main() { | |
SystemChrome.setPreferredOrientations([ | |
DeviceOrientation.landscapeLeft, | |
DeviceOrientation.landscapeRight, | |
]).then((_) { | |
runApp(new MyApp()); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
iPadの時はそれだけでは足りないので注意ですね。
flutter/flutter#27235