Skip to main content

VisualDensity

Struct VisualDensity 

Source
pub struct VisualDensity {
    pub horizontal: f32,
    pub vertical: f32,
}
Expand description

How compact the controls are — the reference’s VisualDensity.

Two numbers from −4 to 4, one per axis. Each step is four logical pixels on a control’s base size: a button at the compact density (−2, −2) is 8 px shorter than at the standard one, and its padding loses 8 px across. Zero is the standard density.

A theme carries one (Theme::visual_density). Unset, it follows the theme’s platform as the reference’s does (default_for_platform): standard on phones, compact on the desktops, where a pointer is precise and a screen holds more.

Fields§

§horizontal: f32

Across: negative is narrower.

§vertical: f32

Down: negative is shorter.

Implementations§

Source§

impl VisualDensity

Source

pub const MINIMUM: f32 = -4.0

The smallest a density goes.

Source

pub const MAXIMUM: f32 = 4.0

The largest a density goes.

Source

pub const STANDARD: Self

The design’s own size.

Source

pub const COMFORTABLE: Self

A step tighter than standard on both axes.

Source

pub const COMPACT: Self

Two steps tighter on both axes: the desktops’ default.

Source

pub fn new(horizontal: f32, vertical: f32) -> Self

A density of horizontal and vertical, each kept within MINIMUM..=MAXIMUM.

Source

pub const fn default_for_platform(platform: TargetPlatform) -> Self

The density a platform’s controls have: standard on Android, iOS and Fuchsia, compact on Linux, macOS and Windows (theme_data.dart:3252).

Source

pub fn base_size_adjustment(self) -> (f32, f32)

What it adds to a control’s base size, in logical pixels: four per step, on each axis (theme_data.dart:3307).

Source

pub fn effective_min_size( self, (min_width, min_height): (f32, f32), (max_width, max_height): (f32, f32), ) -> (f32, f32)

A minimum size, adjusted: min_width and min_height moved by the adjustment, never below zero nor above max_width and max_height (theme_data.dart:3332).

Source

pub fn lerp(a: Self, b: Self, t: f32) -> Self

Between a and b at t.

Trait Implementations§

Source§

impl Clone for VisualDensity

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for VisualDensity

Source§

impl Debug for VisualDensity

Source§

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

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

impl Default for VisualDensity

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for VisualDensity

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for VisualDensity

Auto Trait Implementations§

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.