Skip to main content

MediaQuery

Struct MediaQuery 

Source
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:

  • WidgetsApp and MaterialApp, which introduce a MediaQuery and 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>§data: MediaQueryData

Contains information about the current media.

For example, the MediaQueryData::size property contains the width and height of the current window.

§child: WidgetRef

The widget below this widget in the tree.

Implementations§

Source§

impl MediaQuery

Source

pub fn new<K>(data: MediaQueryData, child: impl IntoWidget<K>) -> MediaQuery

Creates a widget that provides MediaQueryData to its descendants.

Source

pub fn key(self, key: KeyRef) -> MediaQuery

Dart MediaQuery(key:).

Source

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.

Source

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:

Source

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:

Source

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:

Source

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:

Source

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.

Source

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.

Source

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.

Source

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 a MediaQuery ancestor. It returns None instead.
  • size_of and other specific methods for retrieving and depending on changes of a specific value.
Source

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 a MediaQuery ancestor, instead of returning None.
  • maybe_size_of and other specific methods for retrieving and depending on changes of a specific value.
Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn accessible_navigation_of(app: &mut App, context: BuildContext) -> bool

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.

Source

pub fn maybe_accessible_navigation_of( app: &mut App, context: BuildContext, ) -> Option<bool>

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn navigation_mode_of( app: &mut App, context: BuildContext, ) -> NavigationMode

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.

Source

pub fn maybe_navigation_mode_of( app: &mut App, context: BuildContext, ) -> Option<NavigationMode>

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.

Source

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.

Source

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.

Source

pub fn supports_showing_system_context_menu( app: &mut App, context: BuildContext, ) -> bool

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.

Source

pub fn maybe_supports_showing_system_context_menu( app: &mut App, context: BuildContext, ) -> Option<bool>

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl InheritedModel for MediaQuery

Source§

type Aspect = MediaQueryAspect

The type of the model aspect objects; Dart’s T.
Source§

fn update_should_notify_dependent( &self, old_widget: &MediaQuery, dependencies: &HashSet<MediaQueryAspect>, ) -> bool

Return true if the changes between this model and old_widget match any of the dependencies.
Source§

fn is_supported_aspect(&self, aspect: &Self::Aspect) -> bool

Returns true if this model supports the given aspect. Read more
Source§

fn inherit_from( app: &mut App, context: BuildContext, aspect: Option<Self::Aspect>, ) -> Option<&Self>
where Self: Sized,

Makes context dependent on the specified aspect of an InheritedModel of this type. Read more
Source§

impl InheritedWidget for MediaQuery

Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s 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 child(&self) -> &WidgetRef

The widget below this widget in the tree.
Source§

fn update_should_notify(&self, old_widget: &MediaQuery) -> bool

Whether the framework should notify widgets that inherit from this widget. Read more
Source§

fn debug_check_constructor(&self)

Source§

fn as_inherited_theme(&self) -> Option<&dyn InheritedTheme>

Dart’s 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 MediaQuery
where *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
where Rc<dyn Key>: Unpin, Box<TextScaler>: Unpin, *const u8 is !null: Unpin, Rc<dyn Widget>: Unpin,

§

impl UnsafeUnpin for MediaQuery

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> IntoWidget<InheritedKind> for W
where W: InheritedWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<W> IntoWidget<InheritedModelKind> for W
where W: InheritedModel,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>