ViewPortWidget class
InheritedWidget holding a ViewPort configuration.
As any inherited widget, to provide an effect to the application, it should be accessible to the user widget from the parents chain.
class ParentWidget extends StatelessWidget {
// ...
@override
Widget build(BuildContext context) {
return ViewPortWidget.upperBoundedMediaQuery(
maxWidth: 1024.0,
child: const ViewPortUserWidget(),
);
}
}
class ViewPortUserWidget extends StatelessWidget {
// ...
@override
Widget build(BuildContext context) {
return Container(
width: ViewPort.of(context).width * 0.6,
child: ...,
);
}
}
It makes use of WidgetViewPortFactory to support dynamic calculations (as ViewPort instances operate purely on their fields to evaluate the result and convenient access interface such as ViewPort.of would be impossible). So the default constructor takes a WidgetViewPortFactory instance, and there are a bunch of constructors with pre-defined configurations available to simplify the usage for the most common cases, such as:
- ViewPortWidget.fixed - to create a FixedViewPort-backed configuration
- ViewPortWidget.mediaQuery - to create a MediaQuerySizeViewPort-backed configuration
- ViewPortWidget.lowerBoundedMediaQuery - to create a configuration analogous to the dynamic ViewPorts.lowerBoundedMediaQuery
- ViewPortWidget.upperBoundedMediaQuery - to create a configuration analogous to the dynamic ViewPorts.upperBoundedMediaQuery
- ViewPortWidget.coercedMediaQuery - to create a configuration analogous to the dynamic ViewPorts.coercedMediaQuery
See also:
- ViewPort - describes the rendering area size
- ViewPorts - provides common ViewPort configurations
- WidgetViewPortFactory - used to support dynamic ViewPort configuration, which will produce the instance based on the passed BuildContext
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- ProxyWidget
- InheritedWidget
- ViewPortWidget
- Annotations
Constructors
- ViewPortWidget({required WidgetViewPortFactory factory, required Widget child, Key? key})
-
Configures the widget with any passed WidgetViewPortFactory
implementation.
const
- ViewPortWidget.coercedMediaQuery({required Widget child, double maxHeight = double.infinity, double maxWidth = double.infinity, double minHeight = 0, double minWidth = 0, Key? key})
- Provides a coerced MediaQueryData-based ViewPort configuration.
- ViewPortWidget.fixed({required Widget child, double height = double.infinity, double width = double.infinity, Key? key})
- Provides a fixed ViewPort configuration.
- ViewPortWidget.lowerBoundedMediaQuery({required Widget child, double minHeight = 0, double minWidth = 0, Key? key})
- Provides a lower-bounded MediaQueryData-based ViewPort configuration.
- ViewPortWidget.mediaQuery({required Widget child, Key? key})
-
Provides a MediaQueryData-based ViewPort configuration.
const
- ViewPortWidget.upperBoundedMediaQuery({required Widget child, double maxHeight = double.infinity, double maxWidth = double.infinity, Key? key})
- Provides an upper-bounded MediaQueryData-based ViewPort configuration.
Properties
- child → Widget
-
The widget below this widget in the tree.
finalinherited
- factory → WidgetViewPortFactory
-
final
- 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
-
createElement(
) → InheritedElement -
Inflates this configuration to a concrete instance.
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.
override
-
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
-
updateShouldNotify(
covariant ViewPortWidget oldWidget) → bool -
Whether the framework should notify widgets that inherit from this widget.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited