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

outdated

Set the device orientation programmatically

auto_orientation #

** iOS only currently **

This plugin was created to programmatically rotate on iOS

Getting Started #

After importing the package you can use AutoOrientation.landscapeMode(); or AutoOrientation.portraitMode();

I've used it for the a VideoScaffold, to programmatically change to landscape and back to portrait if the scaffold is disposed.

class _VideoScaffoldState extends State<VideoScaffold> {
  @override
  void initState() {
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.landscapeRight,
      DeviceOrientation.landscapeLeft,
    ]);
    AutoOrientation.landscapeMode();
    super.initState();
  }

  @override
  dispose(){
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
      DeviceOrientation.portraitDown,
    ]);
    AutoOrientation.portraitMode();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return widget.child;
  }
}
84
likes
0
pub points
97%
popularity

Publisher

unverified uploader

Set the device orientation programmatically

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on auto_orientation