Skip to content

Instantly share code, notes, and snippets.

@ryohtarot
Last active October 26, 2020 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryohtarot/e34b7c17b207e527d9dcfb1f0e9d6ba0 to your computer and use it in GitHub Desktop.
Save ryohtarot/e34b7c17b207e527d9dcfb1f0e9d6ba0 to your computer and use it in GitHub Desktop.
【Flutter】画面を縦/横に固定する方法
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());
});
}
@shinriyo
Copy link

iPadの時はそれだけでは足りないので注意ですね。

flutter/flutter#27235

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment