flutter stateless screen only portrait code example

Example 1: flutter lock orientation


void initState(){
  super.initState();
  SystemChrome.setPreferredOrientations([
      DeviceOrientation.landscapeRight,
      DeviceOrientation.landscapeLeft,
  ]);
}

Example 2: flutter lock orientation

import 'package:flutter/material.dart';  import 'package:flutter/services.dart';   Future main() async {    await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);    runApp(new MyApp());  }   class MyApp extends StatelessWidget {          Widget build(BuildContext context) {      return MaterialApp(        title: 'Welcome to Flutter',        home: Scaffold(          appBar: AppBar(            title: Text('Flutter Display Orientation Tutorial'),          ),          body: Center(            child: Text(                "Woolha.com"            )          ),        ),      );    }  }

Tags:

Dart Example