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

discontinued
outdated

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);
10
likes
30
pub points
16%
popularity

Publisher

unverified uploader

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