Responsive class

Lets you define alternate widgets for different screen sizes.

Different constructors are provided for different use cases. Use Responsive.builder to create a Responsive from a ResponsiveBuilder. Use Responsive.withShared to create a Responsive from a ResponsiveBuilderWithShared to share a Widget between different ResponsiveFormats.

A Screen is considered to be ResponsiveFormat.mobile if the screen width is below the lowerBound (default: 850px). A Screen is considered to be ResponsiveFormat.desktop if the screen width is equal or above the upperBound (default: 1550px). Anything in between is considered a ResponsiveFormat.tablet screen. To customize this behavior, you may override the upperBound and/or lowerBound static properties as well as the isMobile, isDesktop and isTablet static methods.

Inheritance

Constructors

Responsive({Key? key, Widget? onMobile, Widget? onTablet, Widget? onDesktop, ResponsiveFormat? preferredTabletFormat})
Creates a Responsive Widget which returns on of the provided onMobile, onTablet or onDesktop Widgets based on the current ResponsiveFormat.
Responsive.builder({ResponsiveBuilder? onMobile, ResponsiveBuilder? onTablet, ResponsiveBuilder? onDesktop, ResponsiveFormat? preferredTabletFormat})
Creates a Responsive Widget which returns either of the provided onMobile, onTablet or onDesktop Widgets based on the current ResponsiveFormat.

Properties

hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContext context) Widget
the widget build method which returns the chosen 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 Properties

defaultFormat ResponsiveFormat
The default ResponsiveFormat for the Responsive widget. If for any reason no other ResponsiveFormat can be determined, this one is used.
getter/setter pair
isDesktop IsResponsiveFormat
getter/setter pair
isMobile IsResponsiveFormat
getter/setter pair
isTablet IsResponsiveFormat
getter/setter pair
lowerBound double
the lower bound of the screen width. If the screen width is below this value, its considered a ResponsiveFormat.mobile screen.
getter/setter pair
upperBound double
the upper bound of the screen width. If the screen width is equal or above this value, its considered a ResponsiveFormat.desktop screen.
getter/setter pair

Static Methods

getFormat(BuildContext context) ResponsiveFormat
Returns the current ResponsiveFormat based on the isMobile, isDesktop and isTablet methods.
value<T>({required BuildContext context, T? onMobile, T? onDesktop, T? onTablet, ResponsiveFormat? preferredTabletFormat}) → T
Creates a simple Value of one of the provided onMobile, onTablet or onDesktop values based on the current ResponsiveFormat.
withShared<T>({ResponsiveBuilderWithShared<T>? onMobile, ResponsiveBuilderWithShared<T>? onTablet, ResponsiveBuilderWithShared<T>? onDesktop, required T share, ResponsiveFormat? preferredTabletFormat}) Responsive
Creates a Responsive Widget which returns either of the provided onMobile, onTablet or onDesktop Widgets based on the current ResponsiveFormat.