device_orientation_detector 1.0.3 copy "device_orientation_detector: ^1.0.3" to clipboard
device_orientation_detector: ^1.0.3 copied to clipboard

A Flutter plugin to detect device orientation changes using native sensors, even when screen rotation is locked. No special permissions required.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: OrientationListener());
  }
}

class OrientationListener extends StatefulWidget {
  const OrientationListener({super.key});
  @override
  State<OrientationListener> createState() => _OrientationListenerState();
}

class _OrientationListenerState extends State<OrientationListener> {
  String _orientation = "portrait";

  @override
  void initState() {
    super.initState();
    DeviceOrientationPlugin.instance.orientationStream.listen((orientation) {
      setState(() {
        _orientation = orientation;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Device Orientation Detector")),
      body: Center(
        child: Text(
          "Current Orientation: $_orientation",
          style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
        ),
      ),
    );
  }
}
0
likes
160
points
170
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to detect device orientation changes using native sensors, even when screen rotation is locked. No special permissions required.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on device_orientation_detector

Packages that implement device_orientation_detector