coercedMediaQuery method
- MediaQueryData data, {
- double minHeight = 0,
- double minWidth = 0,
- double maxHeight = double.infinity,
- double maxWidth = double.infinity,
Provides a ViewPort which will produce the data
's size values that are
lower bounded by the given minHeight
and minWidth
and upper bounded by
the given maxHeight
and maxWidth
Simply said, if the data
size values are lesser than the defined bounds,
then bound values are returned (e.g. data.size.width = 300 and
minWidth
= 400, then 400 will be returned). The same applies for the
upper bounds (e.g. data.size.width = 1200 and maxWidth
= 1024, then 1024
will be returned).
minWidth
describes the width's lower bound, minHeight
- height's lower
bound. The lower bounds are 0 by default. maxWidth
describes the width's
upper bound, maxHeight
- height's upper bound. The lower bounds are set
to double.infinity by default.
Invocation of this method with all the parameters provided with the
default values will produce no additional effect over the direct
data
's size instance usage unless there are specific cases like
data.size.width resulting into double.infinity, for which the
result is unspecified.
final ViewPort vp = const ViewPorts().coercedMediaQuery(
MediaQuery.of(context),
minWidth: 200.0,
maxWidth: 1024.0,
);
Implementation
ViewPort coercedMediaQuery(
MediaQueryData data, {
double minHeight = 0,
double minWidth = 0,
double maxHeight = double.infinity,
double maxWidth = double.infinity,
}) =>
coerced(
fromMediaQueryData(data),
minHeight: minHeight,
maxHeight: maxHeight,
minWidth: minWidth,
maxWidth: maxWidth,
);