ResponsiveLayout class
A Widget that chooses another Widget to display based on the screen size.
The default screen axis is horizontal (screen width). The displayed Widget
is chosen based on the greatest provided breakpoint that satisfies
current screen [axis] size > breakpoint
The default breakpoints are:
- xs: < 576
- sm: >= 578
- md: >= 768
- lg: >= 992
- xl: >= 1200
- xxl: >= 1400
A Text Widget reading '>= 768' will be displayed by the following example
if the screen width is 800px. If the width was 1150px the result would still
be the same as no 'lg' breakpoint was provided and it defaults to the
next smallest. One-off sizes can be provided using a custom
mapping.
ResponsiveLayout(
Breakpoints(
sm: Text('>= 576'),
md: Text('>= 768'),
xl: Text('>= 1200'),
custom: { 1600: Text('>= 1600') },
),
);
WidgetBuilders can be used instead of Widgets to avoid building the Widget prior to ResponsiveLayout deciding which to display.
ResponsiveLayout.builder(
Breakpoints(
sm: (context) => Text('>= 576'),
md: (context) => Text('>= 768'),
xl: (context) => Text('>= 1200'),
custom: { 1600: (context) => Text('>= 1600') },
),
);
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- ResponsiveLayout
- Implementers
Constructors
-
ResponsiveLayout(BaseBreakpoints<
Widget> breakpoints, {Axis axis = Axis.horizontal, Key? key}) - Creates a Widget that chooses another Widget to display based on the screen size.
-
ResponsiveLayout.builder(BaseBreakpoints<
WidgetBuilder?> breakpoints, {Axis axis = Axis.horizontal, Key? key}) - Creates a Widget that chooses another Widget to display based on the screen size using a WidgetBuilder.
Properties
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
Static Methods
-
value<
T> (BuildContext context, BaseBreakpoints< T?> breakpoints, {Axis axis = Axis.horizontal}) → T