VisualDensity class

Defines the visual density of user interface components.

Density, in the context of a UI, is the vertical and horizontal "compactness" of the components in the UI. It is unitless, since it means different things to different UI components.

The default for visual densities is zero for both vertical and horizontal densities, which corresponds to the default visual density of components in the Material Design specification. It does not affect text sizes, icon sizes, or padding values.

For example, for buttons, it affects the spacing around the child of the button. For lists, it affects the distance between baselines of entries in the list. For chips, it only affects the vertical size, not the horizontal size.

See also:

Mixed in types


VisualDensity({double horizontal: 0.0, double vertical: 0.0})
A const constructor for VisualDensity. [...]


baseSizeAdjustment Offset
The base adjustment in logical pixels of the visual density of UI components. [...]
hashCode int
The hash code for this object. [...]
read-only, override
horizontal double
The horizontal visual density of UI components. [...]
vertical double
The vertical visual density of UI components. [...]
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


copyWith({double horizontal, double vertical}) VisualDensity
Copy the current VisualDensity with the given values replacing the current values.
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
effectiveConstraints(BoxConstraints constraints) BoxConstraints
Return a copy of constraints whose minimum width and height have been updated with the baseSizeAdjustment.
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toDiagnosticsNode({String name, DiagnosticsTreeStyle style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
toString({DiagnosticLevel minLevel:}) String
Returns a string representation of this object.


operator ==(Object other) bool
The equality operator. [...]

Static Properties

adaptivePlatformDensity VisualDensity
Returns a visual density that is adaptive based on the defaultTargetPlatform. [...]

Static Methods

lerp(VisualDensity a, VisualDensity b, double t) VisualDensity
Linearly interpolate between two densities.


comfortable → const VisualDensity
The profile for a "comfortable" interpretation of VisualDensity. [...]
VisualDensity(horizontal: -1.0, vertical: -1.0)
compact → const VisualDensity
The profile for a "compact" interpretation of VisualDensity. [...]
VisualDensity(horizontal: -2.0, vertical: -2.0)
maximumDensity → const double
The maximum allowed density.
minimumDensity → const double
The minimum allowed density.
standard → const VisualDensity
The default profile for VisualDensity in ThemeData. [...]