flutter_orientation 1.0.0 copy "flutter_orientation: ^1.0.0" to clipboard
flutter_orientation: ^1.0.0 copied to clipboard

A flutter plugin for rotate device orientation.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_orientation/flutter_orientation.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: ElevatedButton(
            child: Text('rotate'),
            onPressed: () {
              if (MediaQuery.of(context).orientation == Orientation.portrait) {
                FlutterOrientation.setOrientation(DeviceOrientation.landscapeRight);
              } else {
                FlutterOrientation.setOrientation(DeviceOrientation.portraitUp);
              }
            },
          ),
        ),
      ),
    );
  }
}
0
likes
110
pub points
35%
popularity

Publisher

unverified uploader

A flutter plugin for rotate device orientation.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_orientation