orientation_helper 1.1.0 copy "orientation_helper: ^1.1.0" to clipboard
orientation_helper: ^1.1.0 copied to clipboard

discontinued

A Flutter plugin to easily handle screen orientation for every route in your app.

orientation_helper #

A Flutter plugin to easily handle screen orientation for every route in your app.

Portrait Only

Rotation

Getting Started #

Create routes and set their orientation:

class AppRoutes {
  // has defaultOrientation
  static var home = RouteDetails(
    name: 'home',
    page: HomePage(),
  );
  static var details = RouteDetails(
    name: '/details',
    page: DetailsPage(),
    orientation: ScreenOrientation.rotating,
  );

  static List<RouteDetails> get routes => [
        home,
        details,
      ];
}

Setup OrientationHelper:


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

class _MyAppState extends State<MyApp> {
OrientationHelper orientationHelper;

@override
void initState() {
 orientationHelper = OrientationHelper(
   routes: AppRoutes.routes,
   defaultOrientation: ScreenOrientation.portraitOnly,
 );
 super.initState();
}

@override
Widget build(BuildContext context) {
 return MaterialApp(
   /// Setup OrientationHelper
   initialRoute: AppRoutes.home.name,
   navigatorObservers: [
     orientationHelper.navigatorObserver,
   ],
   onGenerateRoute: orientationHelper.onGenerateRoute,
 );
}
}

Navigate with pushNamed:

Navigator.of(context).pushNamed(AppRoutes.details.name);

Pass arguments:

Navigator.of(context).pushNamed(AppRoutes.details.name, arguments: 'Argument');

Get arguments:

class DetailsPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
        final dynamic arguments = (ModalRoute.of(context).settings.arguments as RouteArguments).args;
    return Child();
  }
}
10
likes
30
points
32
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to easily handle screen orientation for every route in your app.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, pedantic

More

Packages that depend on orientation_helper