TwoPane class
A widget that positions two panes side by side on uninterrupted screens or on either side of a separating DisplayFeature on screens interrupted by a separating DisplayFeature.
A DisplayFeature separates the screen into sub-screens when both these conditions are met:
- it obstructs the screen, meaning the area it occupies is not 0. Display features of type DisplayFeatureType.fold can have height 0 or width 0 and not be obstructing the screen.
- it is at least as tall as the screen, producing a left and right sub-screen or it is at least as wide as the screen, producing a top and bottom sub-screen.
When positioning the two panes, direction, paneProportion and panePriority parameters are ignored and values are replaced in order to avoid the separating DisplayFeature:
- On screens with a separating DisplayFeature, the two panes are positioned on each side of the feature. If the DisplayFeature splits the screen left and right, direction is Axis.horizontal. Otherwise, direction is Axis.vertical. The paneProportion and panePriority parameters are also ignored and each pane occupies a sub-screen.
- On screens without a separating DisplayFeature, direction is used for deciding if the 2 panes are laid out horizontally or vertically and paneProportion is used for deciding how much space each pane takes.
This widget is similar to Flex and also takes textDirection and verticalDirection parameters, which are used for deciding in what order the panes are laid out (e.g TextDirection.ltr would position startPane on the left and endPane on the right).
The panePriority parameter can be used to display only one pane on screens without any separating DisplayFeature, by using TwoPanePriority.start or TwoPanePriority.end. When TwoPanePriority.both is used or when the screen has a separating DisplayFeature, both panes are visible.
Similarly to SafeArea and DisplayFeatureSubScreen, this widget assumes there is no distance between it and the first MediaQuery ancestor. If this is not true, the bounds of display features will not align with the separation between the two panes. The padding parameter can be used to align TwoPane with the real position of display features. The padding parameter is the padding between TwoPane and the edges of the screen.
Pane widgets are wrapped in modified MediaQuery parents, removing padding, insets and display features that no longer intersect with them.
If not provided, textDirection defaults to the ambient Directionality. If none are provided, then the widget asserts during build in debug mode. The resolved direction of TwoPane is Axis.horizontal when there are display features separating the screen into two horizontal sub-screens, in which case the provided direction is ignored.
See also
- DisplayFeature and MediaQueryData.displayFeatures, to further understand display features
- MediaQueryData.removeDisplayFeatures which is used to remove padding, insets and display features for each pane.
- Inheritance
Constructors
-
TwoPane({Key? key, required Widget startPane, required Widget endPane, double paneProportion = 0.5, TextDirection? textDirection, VerticalDirection verticalDirection = VerticalDirection.down, Axis direction = Axis.horizontal, TwoPanePriority panePriority = TwoPanePriority.both, EdgeInsets padding = EdgeInsets.zero, Set<
TwoPaneAllowedOverrides> allowedOverrides = const {TwoPaneAllowedOverrides.paneProportion, TwoPaneAllowedOverrides.direction, TwoPaneAllowedOverrides.panePriority}}) -
Create a layout that shows two pane widgets side by side.
const
Properties
-
allowedOverrides
→ Set<
TwoPaneAllowedOverrides> -
The parameters that TwoPane is allowed to override when a separating
display feature is found.
final
- direction → Axis
-
Same as Flex.direction.
final
- endPane → Widget
-
The second pane.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- padding → EdgeInsets
-
The padding between TwoPane and the edges of the screen.
final
- panePriority → TwoPanePriority
-
Whether to show only one pane and which one, or both.
final
- paneProportion → double
-
Proportion of the available space occupied by the first pane. The second
pane takes over the rest of the screen.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- startPane → Widget
-
The first pane.
final
- textDirection → TextDirection?
-
Same as Flex.textDirection.
final
- verticalDirection → VerticalDirection
-
Same as Flex.verticalDirection.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → 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