device_orientation_for_x 0.0.2 copy "device_orientation_for_x: ^0.0.2" to clipboard
device_orientation_for_x: ^0.0.2 copied to clipboard

Check how the device is rotated even if system rotation is disabled and make sure widgets are always pointing down.

example/lib/main.dart

import 'package:device_orientation_for_x/device_orientation.dart';
import 'package:device_orientation_for_x/widgets/always_down.dart';
import 'package:device_orientation_for_x/widgets/animated_always_down.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() => boot();

Future<void> boot() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) => MaterialApp(
        title: 'Absolute device rotation demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: const ExamplePage(),
      );
}

class ExamplePage extends StatelessWidget {
  const ExamplePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(
          title: const Text('Down pointers example'),
          systemOverlayStyle: SystemUiOverlayStyle.light,
        ),
        body: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            StreamBuilder<DeviceOrientation>(
              stream: deviceOrientation$,
              initialData: deviceOrientation,
              builder: (context, snapshot) => Text(snapshot.data!.name),
            ),
            const Center(
              child: Icon(Icons.smartphone, size: 64),
            ),
            const Center(
              child: Icon(Icons.arrow_downward, size: 64),
            ),
            const Center(
              child: AlwaysDown(
                child: Icon(Icons.arrow_downward, size: 64),
              ),
            ),
            const Center(
              child: AnimatedAlwaysDown(
                child: Icon(Icons.arrow_downward, size: 64),
              ),
            ),
          ],
        ),
      );
}
0
likes
130
points
29
downloads

Publisher

unverified uploader

Weekly Downloads

Check how the device is rotated even if system rotation is disabled and make sure widgets are always pointing down.

Repository (GitLab)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, sensors_plus

More

Packages that depend on device_orientation_for_x