pub struct MediaQuery {
pub key: Option<KeyRef>,
pub data: MediaQueryData,
pub child: WidgetRef,
}Expand description
Establishes a subtree in which media queries resolve to the given data.
For example, to learn the size of the current view (e.g., the view containing your app),
you can use MediaQuery::size_of: MediaQuery::size_of(app, context).
Querying the current media using specific methods (for example, MediaQuery::size_of
or MediaQuery::padding_of) will cause your widget to rebuild automatically whenever
that specific property changes.
Querying using MediaQuery::of will cause your widget to rebuild automatically
whenever any field of the MediaQueryData changes (e.g., if the user rotates their
device). Therefore, unless you are concerned with the entire MediaQueryData object
changing, prefer using the specific methods (for example: MediaQuery::size_of and
MediaQuery::padding_of), as it will rebuild more efficiently.
If no MediaQuery is in scope then MediaQuery::of and the “…Of” methods similar
to MediaQuery::size_of will panic. Alternatively, the “maybe-” variant methods (such
as MediaQuery::maybe_of and MediaQuery::maybe_size_of) can be used, which return
None, instead of panicking, when no MediaQuery is in scope.
See also:
WidgetsAppandMaterialApp, which introduce aMediaQueryand keep it up to date with the current screen metrics as they change.MediaQueryData, the data structure that represents the metrics.
Fields§
§key: Option<KeyRef>See InheritedWidget::key.
data: MediaQueryDataContains information about the current media.
For example, the MediaQueryData::size property contains the width and height of
the current window.
child: WidgetRefThe widget below this widget in the tree.
Implementations§
Source§impl MediaQuery
impl MediaQuery
Sourcepub fn new<K>(data: MediaQueryData, child: impl IntoWidget<K>) -> MediaQuery
pub fn new<K>(data: MediaQueryData, child: impl IntoWidget<K>) -> MediaQuery
Creates a widget that provides MediaQueryData to its descendants.
Sourcepub fn key(self, key: KeyRef) -> MediaQuery
pub fn key(self, key: KeyRef) -> MediaQuery
Dart MediaQuery(key:).
Sourcepub fn into_widget(self) -> WidgetRef
pub fn into_widget(self) -> WidgetRef
The tree node for this widget.
A model is both an InheritedWidget and an InheritedModel, so the kind tag of
IntoWidget cannot be inferred for it; this names the conversion.
Sourcepub fn remove_padding<K>(
app: &mut App,
context: BuildContext,
remove_left: bool,
remove_top: bool,
remove_right: bool,
remove_bottom: bool,
child: impl IntoWidget<K>,
) -> MediaQuery
pub fn remove_padding<K>( app: &mut App, context: BuildContext, remove_left: bool, remove_top: bool, remove_right: bool, remove_bottom: bool, child: impl IntoWidget<K>, ) -> MediaQuery
Creates a new MediaQuery that inherits from the ambient MediaQuery from the
given context, but removes the specified padding.
This should be inserted into the widget tree when the MediaQuery padding is
consumed by a widget in such a way that the padding is no longer exposed to the
widget’s descendants or siblings.
The context argument must have a MediaQuery in scope.
If all four of the remove_left, remove_top, remove_right, and remove_bottom
arguments are false, then the returned MediaQuery reuses the ambient
MediaQueryData unmodified, which is not particularly useful.
See also:
SafeArea, which both removes the padding from theMediaQueryand adds aPaddingwidget.MediaQueryData::padding, the affected property of theMediaQueryData.remove_view_insets, the same thing but forMediaQueryData::view_insets.remove_view_padding, the same thing but forMediaQueryData::view_padding.
Sourcepub fn remove_view_insets<K>(
app: &mut App,
context: BuildContext,
remove_left: bool,
remove_top: bool,
remove_right: bool,
remove_bottom: bool,
child: impl IntoWidget<K>,
) -> MediaQuery
pub fn remove_view_insets<K>( app: &mut App, context: BuildContext, remove_left: bool, remove_top: bool, remove_right: bool, remove_bottom: bool, child: impl IntoWidget<K>, ) -> MediaQuery
Creates a new MediaQuery that inherits from the ambient MediaQuery from the
given context, but removes the specified view insets.
This should be inserted into the widget tree when the MediaQuery view insets are
consumed by a widget in such a way that the view insets are no longer exposed to the
widget’s descendants or siblings.
The context argument must have a MediaQuery in scope.
If all four of the remove_left, remove_top, remove_right, and remove_bottom
arguments are false, then the returned MediaQuery reuses the ambient
MediaQueryData unmodified, which is not particularly useful.
See also:
MediaQueryData::view_insets, the affected property of theMediaQueryData.remove_padding, the same thing but forMediaQueryData::padding.remove_view_padding, the same thing but forMediaQueryData::view_padding.
Sourcepub fn remove_view_padding<K>(
app: &mut App,
context: BuildContext,
remove_left: bool,
remove_top: bool,
remove_right: bool,
remove_bottom: bool,
child: impl IntoWidget<K>,
) -> MediaQuery
pub fn remove_view_padding<K>( app: &mut App, context: BuildContext, remove_left: bool, remove_top: bool, remove_right: bool, remove_bottom: bool, child: impl IntoWidget<K>, ) -> MediaQuery
Creates a new MediaQuery that inherits from the ambient MediaQuery from the
given context, but removes the specified view padding.
This should be inserted into the widget tree when the MediaQuery view padding is
consumed by a widget in such a way that the view padding is no longer exposed to the
widget’s descendants or siblings.
The context argument must have a MediaQuery in scope.
If all four of the remove_left, remove_top, remove_right, and remove_bottom
arguments are false, then the returned MediaQuery reuses the ambient
MediaQueryData unmodified, which is not particularly useful.
See also:
MediaQueryData::view_padding, the affected property of theMediaQueryData.remove_padding, the same thing but forMediaQueryData::padding.remove_view_insets, the same thing but forMediaQueryData::view_insets.
Sourcepub fn apply_text_style_overrides<K>(
key: Option<KeyRef>,
line_height_scale_factor_override: Option<f64>,
letter_spacing_override: Option<f64>,
word_spacing_override: Option<f64>,
paragraph_spacing_override: Option<f64>,
child: impl IntoWidget<K>,
) -> WidgetRef
pub fn apply_text_style_overrides<K>( key: Option<KeyRef>, line_height_scale_factor_override: Option<f64>, letter_spacing_override: Option<f64>, word_spacing_override: Option<f64>, paragraph_spacing_override: Option<f64>, child: impl IntoWidget<K>, ) -> WidgetRef
Wraps the child in a MediaQuery with its
MediaQueryData::line_height_scale_factor_override,
MediaQueryData::letter_spacing_override,
MediaQueryData::word_spacing_override,
MediaQueryData::paragraph_spacing_override set to the specified values.
If a text style override argument is None, then the corresponding override in the
updated MediaQueryData is set to None.
The returned widget must be inserted in a widget tree below an existing
MediaQuery widget.
See also:
Sourcepub fn from_view<K>(
key: Option<KeyRef>,
view: ViewRef,
child: impl IntoWidget<K>,
) -> WidgetRef
pub fn from_view<K>( key: Option<KeyRef>, view: ViewRef, child: impl IntoWidget<K>, ) -> WidgetRef
Wraps the child in a MediaQuery which is built using data from the provided
view.
The MediaQuery is constructed using the platform-specific data of the surrounding
MediaQuery and the view-specific data of the provided view. If no surrounding
MediaQuery exists, the platform-specific data is generated from the platform
associated with the provided view. Any information that’s exposed via the platform
is considered platform-specific. Data exposed directly on the view is considered
view-specific.
The injected MediaQuery updates when the surrounding MediaQuery or the view
changes, and when the platform tells the binding’s observers its data changed.
Sourcepub fn with_no_text_scaling<K>(
key: Option<KeyRef>,
child: impl IntoWidget<K>,
) -> WidgetRef
pub fn with_no_text_scaling<K>( key: Option<KeyRef>, child: impl IntoWidget<K>, ) -> WidgetRef
Wraps the child in a MediaQuery with its MediaQueryData::text_scaler set to
TextScaler::NO_SCALING.
The returned widget must be inserted in a widget tree below an existing
MediaQuery widget.
This can be used to prevent, for example, icon fonts from scaling as the user adjusts the platform’s text scaling value.
Sourcepub fn with_clamped_text_scaling<K>(
_key: Option<KeyRef>,
min_scale_factor: f64,
max_scale_factor: f64,
child: impl IntoWidget<K>,
) -> WidgetRef
pub fn with_clamped_text_scaling<K>( _key: Option<KeyRef>, min_scale_factor: f64, max_scale_factor: f64, child: impl IntoWidget<K>, ) -> WidgetRef
Wraps the child in a MediaQuery and applies TextScaler::clamp on the current
MediaQueryData::text_scaler.
The returned widget must be inserted in a widget tree below an existing
MediaQuery widget.
This is a convenience function to restrict the range of the scaled text size to
[min_scale_factor * font_size, max_scale_factor * font_size] (to prevent excessive
text scaling that would break the UI, for example). When min_scale_factor equals
max_scale_factor, the scaler becomes TextScaler::linear(min_scale_factor).
Dart accepts a key here and does not pass it to its Builder; neither does this.
Sourcepub fn of(app: &mut App, context: BuildContext) -> MediaQueryData
pub fn of(app: &mut App, context: BuildContext) -> MediaQueryData
The data from the closest instance of this class that encloses the given context.
You can use this function to query the entire set of data held in the current
MediaQueryData object. When any of that information changes, your widget will be
scheduled to be rebuilt, keeping your widget up-to-date.
Since it is typical that the widget only requires a subset of properties of the
MediaQueryData object, prefer using the more specific methods (for example:
size_of and padding_of), as those methods
will not cause a widget to rebuild when unrelated properties are updated.
Typical usage is as follows:
let media = MediaQuery::of(app, context);If there is no MediaQuery in scope, this method panics.
See also:
maybe_of, which doesn’t panic if it doesn’t find aMediaQueryancestor. It returnsNoneinstead.size_ofand other specific methods for retrieving and depending on changes of a specific value.
Sourcepub fn maybe_of(app: &mut App, context: BuildContext) -> Option<MediaQueryData>
pub fn maybe_of(app: &mut App, context: BuildContext) -> Option<MediaQueryData>
The data from the closest instance of this class that encloses the given context, if any.
Use this function if you want to allow situations where no MediaQuery is in
scope. Prefer using of in situations where a media query is always
expected to exist.
If there is no MediaQuery in scope, then this function will return None.
You can use this function to query the entire set of data held in the current
MediaQueryData object. When any of that information changes, your widget will be
scheduled to be rebuilt, keeping your widget up-to-date.
Since it is typical that the widget only requires a subset of properties of the
MediaQueryData object, prefer using the more specific methods (for example:
maybe_size_of and
maybe_padding_of), as those methods will not cause a
widget to rebuild when unrelated properties are updated.
Typical usage is as follows:
let Some(media_query) = MediaQuery::maybe_of(app, context) else {
// Do something else instead.
};See also:
of, which will panic if it doesn’t find aMediaQueryancestor, instead of returningNone.maybe_size_ofand other specific methods for retrieving and depending on changes of a specific value.
Sourcepub fn size_of(app: &mut App, context: BuildContext) -> Size
pub fn size_of(app: &mut App, context: BuildContext) -> Size
Returns MediaQueryData::size from the nearest MediaQuery ancestor or panics,
if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::size property of the ancestor MediaQuery changes.
Prefer using this function over getting the attribute directly from the
MediaQueryData returned from of, because using this function will
only rebuild the context when this specific attribute changes, not when any
attribute changes.
Sourcepub fn maybe_size_of(app: &mut App, context: BuildContext) -> Option<Size>
pub fn maybe_size_of(app: &mut App, context: BuildContext) -> Option<Size>
Returns MediaQueryData::size from the nearest MediaQuery ancestor or None,
if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::size property of the ancestor MediaQuery changes.
Prefer using this function over getting the attribute directly from the
MediaQueryData returned from maybe_of, because using this
function will only rebuild the context when this specific attribute changes, not
when any attribute changes.
Sourcepub fn width_of(app: &mut App, context: BuildContext) -> f64
pub fn width_of(app: &mut App, context: BuildContext) -> f64
Returns width of MediaQueryData::size from the nearest MediaQuery ancestor or
panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the width
of MediaQueryData::size property of the ancestor MediaQuery changes.
Sourcepub fn maybe_width_of(app: &mut App, context: BuildContext) -> Option<f64>
pub fn maybe_width_of(app: &mut App, context: BuildContext) -> Option<f64>
Returns width of MediaQueryData::size from the nearest MediaQuery ancestor or
None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the width
of MediaQueryData::size property of the ancestor MediaQuery changes.
Sourcepub fn height_of(app: &mut App, context: BuildContext) -> f64
pub fn height_of(app: &mut App, context: BuildContext) -> f64
Returns height of MediaQueryData::size from the nearest MediaQuery ancestor
or panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the height
of MediaQueryData::size property of the ancestor MediaQuery changes.
Sourcepub fn maybe_height_of(app: &mut App, context: BuildContext) -> Option<f64>
pub fn maybe_height_of(app: &mut App, context: BuildContext) -> Option<f64>
Returns height of MediaQueryData::size from the nearest MediaQuery ancestor
or None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the height
of MediaQueryData::size property of the ancestor MediaQuery changes.
Sourcepub fn orientation_of(app: &mut App, context: BuildContext) -> Orientation
pub fn orientation_of(app: &mut App, context: BuildContext) -> Orientation
Returns MediaQueryData::orientation for the nearest MediaQuery ancestor or
panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::orientation property of the ancestor MediaQuery changes.
Sourcepub fn maybe_orientation_of(
app: &mut App,
context: BuildContext,
) -> Option<Orientation>
pub fn maybe_orientation_of( app: &mut App, context: BuildContext, ) -> Option<Orientation>
Returns MediaQueryData::orientation for the nearest MediaQuery ancestor or
None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::orientation property of the ancestor MediaQuery changes.
Sourcepub fn device_pixel_ratio_of(app: &mut App, context: BuildContext) -> f64
pub fn device_pixel_ratio_of(app: &mut App, context: BuildContext) -> f64
Returns MediaQueryData::device_pixel_ratio for the nearest MediaQuery
ancestor or panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::device_pixel_ratio property of the ancestor MediaQuery
changes.
Sourcepub fn maybe_device_pixel_ratio_of(
app: &mut App,
context: BuildContext,
) -> Option<f64>
pub fn maybe_device_pixel_ratio_of( app: &mut App, context: BuildContext, ) -> Option<f64>
Returns MediaQueryData::device_pixel_ratio for the nearest MediaQuery
ancestor or None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::device_pixel_ratio property of the ancestor MediaQuery
changes.
Sourcepub fn text_scaler_of(app: &mut App, context: BuildContext) -> TextScaler
pub fn text_scaler_of(app: &mut App, context: BuildContext) -> TextScaler
Returns the MediaQueryData::text_scaler for the nearest MediaQuery ancestor
or TextScaler::NO_SCALING if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::text_scaler property of the ancestor MediaQuery changes.
Sourcepub fn maybe_text_scaler_of(
app: &mut App,
context: BuildContext,
) -> Option<TextScaler>
pub fn maybe_text_scaler_of( app: &mut App, context: BuildContext, ) -> Option<TextScaler>
Returns the MediaQueryData::text_scaler for the nearest MediaQuery ancestor
or None if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::text_scaler property of the ancestor MediaQuery changes.
Sourcepub fn platform_brightness_of(
app: &mut App,
context: BuildContext,
) -> Brightness
pub fn platform_brightness_of( app: &mut App, context: BuildContext, ) -> Brightness
Returns MediaQueryData::platform_brightness for the nearest MediaQuery
ancestor or Brightness::Light, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::platform_brightness property of the ancestor MediaQuery
changes.
Sourcepub fn maybe_platform_brightness_of(
app: &mut App,
context: BuildContext,
) -> Option<Brightness>
pub fn maybe_platform_brightness_of( app: &mut App, context: BuildContext, ) -> Option<Brightness>
Returns MediaQueryData::platform_brightness for the nearest MediaQuery
ancestor or None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::platform_brightness property of the ancestor MediaQuery
changes.
Sourcepub fn padding_of(app: &mut App, context: BuildContext) -> EdgeInsets
pub fn padding_of(app: &mut App, context: BuildContext) -> EdgeInsets
Returns MediaQueryData::padding for the nearest MediaQuery ancestor or panics,
if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::padding property of the ancestor MediaQuery changes.
Sourcepub fn maybe_padding_of(
app: &mut App,
context: BuildContext,
) -> Option<EdgeInsets>
pub fn maybe_padding_of( app: &mut App, context: BuildContext, ) -> Option<EdgeInsets>
Returns MediaQueryData::padding for the nearest MediaQuery ancestor or
None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::padding property of the ancestor MediaQuery changes.
Sourcepub fn view_insets_of(app: &mut App, context: BuildContext) -> EdgeInsets
pub fn view_insets_of(app: &mut App, context: BuildContext) -> EdgeInsets
Returns MediaQueryData::view_insets for the nearest MediaQuery ancestor or
panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::view_insets property of the ancestor MediaQuery changes.
Sourcepub fn maybe_view_insets_of(
app: &mut App,
context: BuildContext,
) -> Option<EdgeInsets>
pub fn maybe_view_insets_of( app: &mut App, context: BuildContext, ) -> Option<EdgeInsets>
Returns MediaQueryData::view_insets for the nearest MediaQuery ancestor or
None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::view_insets property of the ancestor MediaQuery changes.
Sourcepub fn system_gesture_insets_of(
app: &mut App,
context: BuildContext,
) -> EdgeInsets
pub fn system_gesture_insets_of( app: &mut App, context: BuildContext, ) -> EdgeInsets
Returns MediaQueryData::system_gesture_insets for the nearest MediaQuery
ancestor or panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::system_gesture_insets property of the ancestor MediaQuery
changes.
Sourcepub fn maybe_system_gesture_insets_of(
app: &mut App,
context: BuildContext,
) -> Option<EdgeInsets>
pub fn maybe_system_gesture_insets_of( app: &mut App, context: BuildContext, ) -> Option<EdgeInsets>
Returns MediaQueryData::system_gesture_insets for the nearest MediaQuery
ancestor or None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::system_gesture_insets property of the ancestor MediaQuery
changes.
Sourcepub fn view_padding_of(app: &mut App, context: BuildContext) -> EdgeInsets
pub fn view_padding_of(app: &mut App, context: BuildContext) -> EdgeInsets
Returns MediaQueryData::view_padding for the nearest MediaQuery ancestor or
panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::view_padding property of the ancestor MediaQuery changes.
Sourcepub fn maybe_view_padding_of(
app: &mut App,
context: BuildContext,
) -> Option<EdgeInsets>
pub fn maybe_view_padding_of( app: &mut App, context: BuildContext, ) -> Option<EdgeInsets>
Returns MediaQueryData::view_padding for the nearest MediaQuery ancestor or
None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::view_padding property of the ancestor MediaQuery changes.
Sourcepub fn always_use_24_hour_format_of(
app: &mut App,
context: BuildContext,
) -> bool
pub fn always_use_24_hour_format_of( app: &mut App, context: BuildContext, ) -> bool
Returns MediaQueryData::always_use_24_hour_format for the nearest MediaQuery
ancestor or panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::always_use_24_hour_format property of the ancestor
MediaQuery changes.
Sourcepub fn maybe_always_use_24_hour_format_of(
app: &mut App,
context: BuildContext,
) -> Option<bool>
pub fn maybe_always_use_24_hour_format_of( app: &mut App, context: BuildContext, ) -> Option<bool>
Returns MediaQueryData::always_use_24_hour_format for the nearest MediaQuery
ancestor or None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::always_use_24_hour_format property of the ancestor
MediaQuery changes.
Returns MediaQueryData::accessible_navigation for the nearest MediaQuery
ancestor or panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::accessible_navigation property of the ancestor MediaQuery
changes.
Returns MediaQueryData::accessible_navigation for the nearest MediaQuery
ancestor or None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::accessible_navigation property of the ancestor MediaQuery
changes.
Sourcepub fn invert_colors_of(app: &mut App, context: BuildContext) -> bool
pub fn invert_colors_of(app: &mut App, context: BuildContext) -> bool
Returns MediaQueryData::invert_colors for the nearest MediaQuery ancestor or
panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::invert_colors property of the ancestor MediaQuery changes.
Sourcepub fn maybe_invert_colors_of(
app: &mut App,
context: BuildContext,
) -> Option<bool>
pub fn maybe_invert_colors_of( app: &mut App, context: BuildContext, ) -> Option<bool>
Returns MediaQueryData::invert_colors for the nearest MediaQuery ancestor or
None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::invert_colors property of the ancestor MediaQuery changes.
Sourcepub fn high_contrast_of(app: &mut App, context: BuildContext) -> bool
pub fn high_contrast_of(app: &mut App, context: BuildContext) -> bool
Returns MediaQueryData::high_contrast for the nearest MediaQuery ancestor or
false, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::high_contrast property of the ancestor MediaQuery changes.
Sourcepub fn maybe_high_contrast_of(
app: &mut App,
context: BuildContext,
) -> Option<bool>
pub fn maybe_high_contrast_of( app: &mut App, context: BuildContext, ) -> Option<bool>
Returns MediaQueryData::high_contrast for the nearest MediaQuery ancestor or
None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::high_contrast property of the ancestor MediaQuery changes.
Sourcepub fn on_off_switch_labels_of(app: &mut App, context: BuildContext) -> bool
pub fn on_off_switch_labels_of(app: &mut App, context: BuildContext) -> bool
Returns MediaQueryData::on_off_switch_labels for the nearest MediaQuery
ancestor or false, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::on_off_switch_labels property of the ancestor MediaQuery
changes.
Sourcepub fn maybe_on_off_switch_labels_of(
app: &mut App,
context: BuildContext,
) -> Option<bool>
pub fn maybe_on_off_switch_labels_of( app: &mut App, context: BuildContext, ) -> Option<bool>
Returns MediaQueryData::on_off_switch_labels for the nearest MediaQuery
ancestor or None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::on_off_switch_labels property of the ancestor MediaQuery
changes.
Sourcepub fn disable_animations_of(app: &mut App, context: BuildContext) -> bool
pub fn disable_animations_of(app: &mut App, context: BuildContext) -> bool
Returns MediaQueryData::disable_animations for the nearest MediaQuery
ancestor or false, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::disable_animations property of the ancestor MediaQuery
changes.
Sourcepub fn maybe_disable_animations_of(
app: &mut App,
context: BuildContext,
) -> Option<bool>
pub fn maybe_disable_animations_of( app: &mut App, context: BuildContext, ) -> Option<bool>
Returns MediaQueryData::disable_animations for the nearest MediaQuery
ancestor or None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::disable_animations property of the ancestor MediaQuery
changes.
Sourcepub fn reduce_motion_of(app: &mut App, context: BuildContext) -> bool
pub fn reduce_motion_of(app: &mut App, context: BuildContext) -> bool
Returns MediaQueryData::reduce_motion for the nearest MediaQuery ancestor or
false, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::reduce_motion property of the ancestor MediaQuery changes.
Sourcepub fn maybe_reduce_motion_of(
app: &mut App,
context: BuildContext,
) -> Option<bool>
pub fn maybe_reduce_motion_of( app: &mut App, context: BuildContext, ) -> Option<bool>
Returns MediaQueryData::reduce_motion for the nearest MediaQuery ancestor or
None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::reduce_motion property of the ancestor MediaQuery changes.
Sourcepub fn bold_text_of(app: &mut App, context: BuildContext) -> bool
pub fn bold_text_of(app: &mut App, context: BuildContext) -> bool
Returns the MediaQueryData::bold_text accessibility setting for the nearest
MediaQuery ancestor or false, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::bold_text property of the ancestor MediaQuery changes.
Sourcepub fn maybe_bold_text_of(app: &mut App, context: BuildContext) -> Option<bool>
pub fn maybe_bold_text_of(app: &mut App, context: BuildContext) -> Option<bool>
Returns the MediaQueryData::bold_text accessibility setting for the nearest
MediaQuery ancestor or None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::bold_text property of the ancestor MediaQuery changes.
Sourcepub fn supports_announce_of(app: &mut App, context: BuildContext) -> bool
pub fn supports_announce_of(app: &mut App, context: BuildContext) -> bool
Returns the MediaQueryData::supports_announce accessibility setting for the
nearest MediaQuery ancestor or false, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::supports_announce property of the ancestor MediaQuery
changes. This is especially important for supports_announce because it has a low
frequency change rate. The performance difference between rebuilding for all media
query data changes and only rebuilding for supports_announce is a dramatic
difference.
Sourcepub fn maybe_supports_announce_of(
app: &mut App,
context: BuildContext,
) -> Option<bool>
pub fn maybe_supports_announce_of( app: &mut App, context: BuildContext, ) -> Option<bool>
Returns the MediaQueryData::supports_announce accessibility setting for the
nearest MediaQuery ancestor or None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::supports_announce property of the ancestor MediaQuery
changes.
Returns MediaQueryData::navigation_mode for the nearest MediaQuery ancestor
or panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::navigation_mode property of the ancestor MediaQuery changes.
Returns MediaQueryData::navigation_mode for the nearest MediaQuery ancestor
or None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::navigation_mode property of the ancestor MediaQuery changes.
Sourcepub fn gesture_settings_of(
app: &mut App,
context: BuildContext,
) -> DeviceGestureSettings
pub fn gesture_settings_of( app: &mut App, context: BuildContext, ) -> DeviceGestureSettings
Returns MediaQueryData::gesture_settings for the nearest MediaQuery ancestor
or panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::gesture_settings property of the ancestor MediaQuery changes.
Sourcepub fn maybe_gesture_settings_of(
app: &mut App,
context: BuildContext,
) -> Option<DeviceGestureSettings>
pub fn maybe_gesture_settings_of( app: &mut App, context: BuildContext, ) -> Option<DeviceGestureSettings>
Returns MediaQueryData::gesture_settings for the nearest MediaQuery ancestor
or None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::gesture_settings property of the ancestor MediaQuery changes.
Returns MediaQueryData::supports_showing_system_context_menu for the nearest
MediaQuery ancestor or panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::supports_showing_system_context_menu property of the ancestor
MediaQuery changes.
Returns MediaQueryData::supports_showing_system_context_menu for the nearest
MediaQuery ancestor or None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::supports_showing_system_context_menu property of the ancestor
MediaQuery changes.
Sourcepub fn maybe_line_height_scale_factor_override_of(
app: &mut App,
context: BuildContext,
) -> Option<f64>
pub fn maybe_line_height_scale_factor_override_of( app: &mut App, context: BuildContext, ) -> Option<f64>
Returns the MediaQueryData::line_height_scale_factor_override for the nearest
MediaQuery ancestor or None, if no such ancestor exists or if the platform has
not specified an override.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::line_height_scale_factor_override property of the ancestor
MediaQuery changes.
Sourcepub fn maybe_letter_spacing_override_of(
app: &mut App,
context: BuildContext,
) -> Option<f64>
pub fn maybe_letter_spacing_override_of( app: &mut App, context: BuildContext, ) -> Option<f64>
Returns the MediaQueryData::letter_spacing_override for the nearest
MediaQuery ancestor or None, if no such ancestor exists or if the platform has
not specified an override.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::letter_spacing_override property of the ancestor MediaQuery
changes.
Sourcepub fn maybe_word_spacing_override_of(
app: &mut App,
context: BuildContext,
) -> Option<f64>
pub fn maybe_word_spacing_override_of( app: &mut App, context: BuildContext, ) -> Option<f64>
Returns the MediaQueryData::word_spacing_override for the nearest MediaQuery
ancestor or None, if no such ancestor exists or if the platform has not specified
an override.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::word_spacing_override property of the ancestor MediaQuery
changes.
Sourcepub fn maybe_paragraph_spacing_override_of(
app: &mut App,
context: BuildContext,
) -> Option<f64>
pub fn maybe_paragraph_spacing_override_of( app: &mut App, context: BuildContext, ) -> Option<f64>
Returns the MediaQueryData::paragraph_spacing_override for the nearest
MediaQuery ancestor or None, if no such ancestor exists or if the platform has
not specified an override.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::paragraph_spacing_override property of the ancestor
MediaQuery changes.
Sourcepub fn display_corner_radii_of(
app: &mut App,
context: BuildContext,
) -> Option<BorderRadius>
pub fn display_corner_radii_of( app: &mut App, context: BuildContext, ) -> Option<BorderRadius>
Returns MediaQueryData::display_corner_radii for the nearest MediaQuery
ancestor or panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::display_corner_radii property of the ancestor MediaQuery
changes.
Sourcepub fn maybe_display_corner_radii_of(
app: &mut App,
context: BuildContext,
) -> Option<BorderRadius>
pub fn maybe_display_corner_radii_of( app: &mut App, context: BuildContext, ) -> Option<BorderRadius>
Returns MediaQueryData::display_corner_radii for the nearest MediaQuery
ancestor or None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::display_corner_radii property of the ancestor MediaQuery
changes.
Sourcepub fn caption_style_of(
app: &mut App,
context: BuildContext,
) -> Option<CaptionStyle>
pub fn caption_style_of( app: &mut App, context: BuildContext, ) -> Option<CaptionStyle>
Returns MediaQueryData::caption_style for the nearest MediaQuery ancestor or
panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::caption_style property of the ancestor MediaQuery changes.
Sourcepub fn maybe_caption_style_of(
app: &mut App,
context: BuildContext,
) -> Option<CaptionStyle>
pub fn maybe_caption_style_of( app: &mut App, context: BuildContext, ) -> Option<CaptionStyle>
Returns MediaQueryData::caption_style for the nearest MediaQuery ancestor or
None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::caption_style property of the ancestor MediaQuery changes.
Sourcepub fn title_bar_area_of(
app: &mut App,
context: BuildContext,
) -> Option<TitleBarArea>
pub fn title_bar_area_of( app: &mut App, context: BuildContext, ) -> Option<TitleBarArea>
Returns MediaQueryData::title_bar_area for the nearest MediaQuery ancestor or
panics, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::title_bar_area property of the ancestor MediaQuery changes.
Sourcepub fn maybe_title_bar_area_of(
app: &mut App,
context: BuildContext,
) -> Option<TitleBarArea>
pub fn maybe_title_bar_area_of( app: &mut App, context: BuildContext, ) -> Option<TitleBarArea>
Returns MediaQueryData::title_bar_area for the nearest MediaQuery ancestor or
None, if no such ancestor exists.
Use of this method will cause the given context to rebuild any time that the
MediaQueryData::title_bar_area property of the ancestor MediaQuery changes.
Trait Implementations§
Source§impl Debug for MediaQuery
impl Debug for MediaQuery
Source§impl InheritedModel for MediaQuery
impl InheritedModel for MediaQuery
Source§type Aspect = MediaQueryAspect
type Aspect = MediaQueryAspect
T.Source§fn update_should_notify_dependent(
&self,
old_widget: &MediaQuery,
dependencies: &HashSet<MediaQueryAspect>,
) -> bool
fn update_should_notify_dependent( &self, old_widget: &MediaQuery, dependencies: &HashSet<MediaQueryAspect>, ) -> bool
old_widget match any of the
dependencies.Source§fn is_supported_aspect(&self, aspect: &Self::Aspect) -> bool
fn is_supported_aspect(&self, aspect: &Self::Aspect) -> bool
aspect. Read moreSource§fn inherit_from(
app: &mut App,
context: BuildContext,
aspect: Option<Self::Aspect>,
) -> Option<&Self>where
Self: Sized,
fn inherit_from(
app: &mut App,
context: BuildContext,
aspect: Option<Self::Aspect>,
) -> Option<&Self>where
Self: Sized,
Source§impl InheritedWidget for MediaQuery
impl InheritedWidget for MediaQuery
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn update_should_notify(&self, old_widget: &MediaQuery) -> bool
fn update_should_notify(&self, old_widget: &MediaQuery) -> bool
Source§fn as_inherited_theme(&self) -> Option<&dyn InheritedTheme>
fn as_inherited_theme(&self) -> Option<&dyn InheritedTheme>
this is InheritedTheme: an inherited widget that is an InheritedTheme
answers with itself, which is what InheritedTheme::capture collects.Auto Trait Implementations§
impl !RefUnwindSafe for MediaQuery
impl !Send for MediaQuery
impl !Sync for MediaQuery
impl !UnwindSafe for MediaQuery
impl Forget for MediaQuery
impl Freeze for MediaQuerywhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const TextScaler is !null: Freeze,
PhantomData<TextScaler>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const RcInner<dyn Widget> is !null: Freeze,
PhantomData<RcInner<dyn Widget>>: Freeze,
impl Move for MediaQuery
impl Unpin for MediaQuery
impl UnsafeUnpin for MediaQuerywhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const TextScaler is !null: UnsafeUnpin,
PhantomData<TextScaler>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<InheritedKind> for Wwhere
W: InheritedWidget,
impl<W> IntoWidget<InheritedKind> for Wwhere
W: InheritedWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.Source§impl<W> IntoWidget<InheritedModelKind> for Wwhere
W: InheritedModel,
impl<W> IntoWidget<InheritedModelKind> for Wwhere
W: InheritedModel,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.