OrientationLocker class
A widget that locks device orientation while it's in the widget tree.
This widget changes the permitted device orientations when it's initialized and restores the default orientations when disposed. Useful for screens that require specific orientations (e.g., video players, games).
Example:
OrientationLocker(
permittedOrientations: [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight],
child: VideoPlayerScreen(),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- OrientationLocker
- Available extensions
Constructors
-
OrientationLocker({List<
DeviceOrientation> permittedOrientations = const [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight], List<DeviceOrientation> defaultOrientations = const [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight, DeviceOrientation.portraitUp, DeviceOrientation.portraitDown], required Widget child, Key? key}) -
Creates an orientation locker widget.
const
Properties
- child → Widget
-
The child widget to display.
final
-
defaultOrientations
→ List<
DeviceOrientation> -
The orientations to restore when this widget is disposed.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
permittedOrientations
→ List<
DeviceOrientation> -
The orientations permitted while this widget is active.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
border(
BuildContext context, {double radius = 5, EdgeInsetsGeometry padding = const EdgeInsets.all(5), Color? borderColor}) → Widget -
Available on Widget, provided by the WidgetExt extension
Wraps this widget in a Container with a border. -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< OrientationLocker> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
expanded(
{int? flex}) → Expanded -
Available on Widget, provided by the WidgetExt extension
Wraps this widget in an Expanded widget. -
flexible(
{int? flex, FlexFit? flexFit}) → Flexible -
Available on Widget, provided by the WidgetExt extension
Wraps this widget in a Flexible widget. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onCenter(
) → Center -
Available on Widget, provided by the WidgetExt extension
Centers this widget using a Center widget. -
onRoundedWhiteContainer(
{Color? bgColor}) → Container -
Available on Widget, provided by the WidgetExt extension
Wraps this widget in a rounded white Container. -
onSafeArea(
) → Widget -
Available on Widget, provided by the WidgetExt extension
Wraps this widget in a SafeArea to avoid system UI intrusions. -
onScroll(
) → Widget -
Available on Widget, provided by the WidgetExt extension
Wraps this widget in a SingleChildScrollView to make it scrollable. -
onWhiteContainer(
) → Container -
Available on Widget, provided by the WidgetExt extension
Wraps this widget in a white Container. -
paddingAll(
double value) → Padding - Wraps this widget with equal padding on all sides.
-
paddingBottom(
double value) → Padding - Wraps this widget with padding only on the bottom.
-
paddingCustom(
EdgeInsetsGeometry padding) → Padding -
Available on Widget, provided by the WidgetExt extension
Wraps this widget with custom Padding. -
paddingHorizontal(
double value) → Padding - Wraps this widget with horizontal padding (left and right).
-
paddingLeft(
double value) → Padding - Wraps this widget with padding only on the left.
-
paddingRight(
double value) → Padding - Wraps this widget with padding only on the right.
-
paddingTLBR(
double top, double left, double bottom, double right) → Padding - Wraps this widget with padding specified individually for each side.
-
paddingTop(
double value) → Padding - Wraps this widget with padding only on the top.
-
paddingVertical(
double value) → Padding - Wraps this widget with vertical padding (top and bottom).
-
paddingVH(
double verticalPadding, double horizontalPadding) → Padding - Wraps this widget with symmetric padding.
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
tooltip(
String? text, {TooltipTriggerMode? tooltipTriggerMode}) → Widget -
Available on Widget, provided by the WidgetExt extension
Wraps this widget with a Tooltip iftextis not null or empty. -
tooltipMsg(
String? text, {TooltipTriggerMode? tooltipTriggerMode}) → Widget -
Available on Widget, provided by the WidgetExt extension
Wraps this widget with a Tooltip iftextis not null or empty. -
tooltipOnTap(
String? text) → Widget -
Available on Widget, provided by the WidgetExt extension
Wraps this widget with a tap-triggered Tooltip. -
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited