【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()); | |
}); | |
} |
コメント
コメントを投稿