void main(){
///
/// Force the layout to Portrait mode
///
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown
]);
runApp(new MyApp());
}
答案 0 :(得分:6)
将此代码放入MyApp()
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<title></title>
</head>
<body>
<div class="container">
<div class="views-exposed-widget">
<div contenteditable id="editable-text-name">
Editable text here.
</div>
</div>
<div class="views-submit-button">
<button id="save-button" type="button" onclick="alert('button clicked.')" class="btn btn-outline-dark">Save</button>
</div>
</div>
</body>
</html>
像下面这样:
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
答案 1 :(得分:1)
以下是适用于Android
和iOS
的代码
Future main() async {
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(new MyApp());
}
答案 2 :(得分:0)
以下代码对我有用。
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_app/splashScreen.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
runApp(MaterialApp(home: splashScreen(),));
}