limiting_direction_csx 0.2.0 copy "limiting_direction_csx: ^0.2.0" to clipboard
limiting_direction_csx: ^0.2.0 copied to clipboard

Limit the rotatable orientation of the screen, also known as the orientation Settings that the interface can support. It should be noted that the orientation set here needs to be included in the suppo [...]

example/lib/main.dart

/*
 * @Author: Cao Shixin
 * @Date: 2020-12-28 15:12:15
 * @LastEditors: Cao Shixin
 * @LastEditTime: 2021-01-14 13:44:10
 * @Description: 
 */
import 'dart:io';

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  if (Platform.isIOS) {
    await LimitingDirectionCsx.setScreenDirection(
        DeviceDirectionMask.Landscape);
  } else {
    await SystemChrome.setPreferredOrientations(
        [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
  }
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    print('>>>>>>>>>>>>>>>${LimitingDirectionCsx().currentDeviceOrientation}');
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text('Plugin example app'),
          ),
          body: StreamBuilder<UIDeviceOrientation>(
            stream: LimitingDirectionCsx().getDeviceDirectionStream(),
            builder: (context, AsyncSnapshot snapshot) {
              return Text('结果:${snapshot.data}');
            },
          )),
    );
  }
}
5
likes
110
pub points
68%
popularity

Publisher

unverified uploader

Limit the rotatable orientation of the screen, also known as the orientation Settings that the interface can support. It should be noted that the orientation set here needs to be included in the supported orientation of the project.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on limiting_direction_csx