lock_orientation 0.0.1 copy "lock_orientation: ^0.0.1" to clipboard
lock_orientation: ^0.0.1 copied to clipboard

PlatformAndroidiOS
outdated

Locking orientation

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:lock_orientation/lock_orientation.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _orientation='init';
  bool islock=false;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(

        body: Center(
          child: Column(mainAxisSize: MainAxisSize.min,
            children: [
              ElevatedButton(onPressed: (){
                getOrientation().then((ori) {
                  setState(() {
                    _orientation=ori.toString();
                  });
                });
              },child: Text(_orientation),),
              Switch(value: islock, onChanged: (v){
                if(islock) {
                  unlockOrientation();
                }else{
                  lockOrientation();
                }
                setState(() {
                  islock=v;
                });
              })
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
130
points
22
downloads

Publisher

unverified uploader

Weekly Downloads

Locking orientation

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on lock_orientation

Packages that implement lock_orientation