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

Lock Orientation Screen is a Flutter package designed to help developers easily lock the screen orientation to portrait mode within their applications. This package simplifies the process by managing [...]

Lock Orientation Screen #

Lock Orientation Screen is a Flutter package designed to help developers easily lock the screen orientation to portrait mode within their applications. This package simplifies the process by managing the system's orientation settings seamlessly.


Features #

  • Locks the screen orientation to portrait mode.
  • Restores the default system orientations when disposed.
  • Easy to integrate and use.

Installation #

Add the following line to your project's pubspec.yaml under dependencies:

dependencies:
  lock_orientation_screen: ^0.0.1

Then, run:

flutter pub get

Usage #

Wrap your app or specific widgets with LockOrientation to lock the orientation to portrait mode.

Example: #

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return LockOrientation(
      child: MaterialApp(
        home: Scaffold(
          appBar: AppBar(title: const Text('Lock Orientation Example')),
          body: const Center(
            child: Text('Portrait Mode Only'),
          ),
        ),
      ),
    );
  }
}

API #

LockOrientation #

Constructor

const LockOrientation({required Widget child, Key? key})
  • child: The widget to display within the locked orientation.
  • key: An optional key for the widget.

Behavior

  • Locks the orientation to portrait when initialized.
  • Restores default orientations when disposed.

How It Works #

LockOrientation uses Flutter's SystemChrome.setPreferredOrientations to control screen orientation:

  • On initialization: Sets orientation to portraitUp and portraitDown.
  • On disposal: Restores all orientations (portraitUp, portraitDown, landscapeLeft, landscapeRight).

Contributing #

Contributions are highly encouraged! If you would like to contribute to LockOrientation, please follow these steps:

  1. Fork the Repository.
  2. Create a New Branch:
    git checkout -b feature/YourFeature
    
  3. Commit Your Changes:
    git commit -m "Add your message"
    
  4. Push to the Branch:
    git push origin feature/YourFeature
    
  5. Open a Pull Request.

Congratulations #

Contributions are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request in the LockOrientation GitHub repository

If you found this guide helpful, don’t forget to ⭐ star this repository on GitHub to show your support!

Thank you for reading!

Contributions #

.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

Contact #

For any questions or inquiries, feel free to reach out:


Thank you for using Lock Orientation!

5
likes
0
points
181
downloads

Publisher

unverified uploader

Weekly Downloads

Lock Orientation Screen is a Flutter package designed to help developers easily lock the screen orientation to portrait mode within their applications. This package simplifies the process by managing the system's orientation settings seamlessly

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on lock_orientation_screen