pub struct BoxDecoration {
pub color: Option<AnyColor>,
pub border: Option<BoxBorderRef>,
pub border_radius: Option<BorderRadiusGeometry>,
pub box_shadow: Option<Vec<BoxShadow>>,
pub gradient: Option<GradientRef>,
pub background_blend_mode: Option<BlendMode>,
pub shape: BoxShape,
}Expand description
An immutable description of how to paint a box.
The box has a border, a body, and may cast a
box_shadow.
image
is deferred (see PORTING.md).
Fields§
§color: Option<AnyColor>The color to fill in the background of the box.
This is ignored if gradient is non-null.
border: Option<BoxBorderRef>A border to draw above the background color.
border_radius: Option<BorderRadiusGeometry>If non-null, the corners of this box are rounded by this
BorderRadius.
Applies only to boxes with rectangular shapes; ignored if
shape is not BoxShape::Rectangle.
box_shadow: Option<Vec<BoxShadow>>A list of shadows cast by this box behind the box.
gradient: Option<GradientRef>A gradient to use when filling the box.
If this is specified, color has no effect.
background_blend_mode: Option<BlendMode>The blend mode applied to the color or
gradient background of the box.
If no color or gradient is provided then the blend
mode has no impact.
shape: BoxShapeThe shape to fill the background color and
gradient into and to cast as the box_shadow.
Implementations§
Source§impl BoxDecoration
impl BoxDecoration
Sourcepub fn new() -> BoxDecoration
pub fn new() -> BoxDecoration
Creates a box decoration.
Chain setters for the fields Dart’s constructor takes as named arguments:
BoxDecoration::new().color(c).border_radius(r).
- If
coloris None, this decoration does not paint a background color. - If
borderis None, this decoration does not paint a border. - If
border_radiusis None, this decoration uses more efficient background painting commands. The border radius must be None ifshapeisBoxShape::Circle. - If
box_shadowis None, this decoration does not paint a shadow. - If
gradientis None, this decoration does not paint gradients. - If
background_blend_modeis None, this decoration paints withBlendMode::SrcOver.
Sourcepub fn color(self, color: impl Into<AnyColor>) -> BoxDecoration
pub fn color(self, color: impl Into<AnyColor>) -> BoxDecoration
The color to fill in the background of the box.
Sourcepub fn border(self, border: impl Into<BoxBorderRef>) -> BoxDecoration
pub fn border(self, border: impl Into<BoxBorderRef>) -> BoxDecoration
A border to draw above the background color.
Sourcepub fn border_radius(
self,
border_radius: impl Into<BorderRadiusGeometry>,
) -> BoxDecoration
pub fn border_radius( self, border_radius: impl Into<BorderRadiusGeometry>, ) -> BoxDecoration
If non-null, the corners of this box are rounded by this radius.
Applies only to boxes with rectangular shapes.
Sourcepub fn box_shadow(self, box_shadow: Vec<BoxShadow>) -> BoxDecoration
pub fn box_shadow(self, box_shadow: Vec<BoxShadow>) -> BoxDecoration
A list of shadows cast by this box behind the box.
Sourcepub fn gradient(self, gradient: impl Into<GradientRef>) -> BoxDecoration
pub fn gradient(self, gradient: impl Into<GradientRef>) -> BoxDecoration
A gradient to use when filling the box.
Sourcepub fn background_blend_mode(
self,
background_blend_mode: BlendMode,
) -> BoxDecoration
pub fn background_blend_mode( self, background_blend_mode: BlendMode, ) -> BoxDecoration
Sourcepub fn shape(self, shape: BoxShape) -> BoxDecoration
pub fn shape(self, shape: BoxShape) -> BoxDecoration
The shape to fill the background into and to cast as the box shadow.
Sourcepub fn copy_with(&self) -> BoxDecoration
pub fn copy_with(&self) -> BoxDecoration
Creates a copy of this object. Chain setters to replace fields
(decoration.copy_with().color(c)).
Sourcepub fn scale(&self, factor: f64) -> BoxDecoration
pub fn scale(&self, factor: f64) -> BoxDecoration
Returns a new box decoration that is scaled by the given factor.
Sourcepub fn lerp(
a: Option<&BoxDecoration>,
b: Option<&BoxDecoration>,
t: f64,
) -> Option<BoxDecoration>
pub fn lerp( a: Option<&BoxDecoration>, b: Option<&BoxDecoration>, t: f64, ) -> Option<BoxDecoration>
Linearly interpolate between two box decorations.
Interpolates each parameter of the box decoration separately.
The shape is not interpolated.
Trait Implementations§
Source§impl Clone for BoxDecoration
impl Clone for BoxDecoration
Source§fn clone(&self) -> BoxDecoration
fn clone(&self) -> BoxDecoration
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BoxDecoration
impl Debug for BoxDecoration
Source§impl Decoration for BoxDecoration
impl Decoration for BoxDecoration
Source§fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
Decoration.debugFillProperties, inherited from Diagnosticable: a subclass
adds its own properties and calls this first, as Dart’s super does.Source§fn debug_assert_is_valid(&self) -> bool
fn debug_assert_is_valid(&self) -> bool
Source§fn padding(&self) -> EdgeInsetsGeometry
fn padding(&self) -> EdgeInsetsGeometry
Source§fn get_clip_path(&self, rect: Rect, text_direction: TextDirection) -> Path
fn get_clip_path(&self, rect: Rect, text_direction: TextDirection) -> Path
Source§fn is_complex(&self) -> bool
fn is_complex(&self) -> bool
Source§fn lerp_from(
&self,
a: Option<&(dyn Decoration + 'static)>,
t: f64,
) -> Option<DecorationRef>
fn lerp_from( &self, a: Option<&(dyn Decoration + 'static)>, t: f64, ) -> Option<DecorationRef>
Decoration (which may be of a
different class) to this. Read moreSource§fn lerp_to(
&self,
b: Option<&(dyn Decoration + 'static)>,
t: f64,
) -> Option<DecorationRef>
fn lerp_to( &self, b: Option<&(dyn Decoration + 'static)>, t: f64, ) -> Option<DecorationRef>
this to another Decoration (which may be of
a different class).Source§fn hit_test(
&self,
size: Size,
position: Offset,
text_direction: Option<TextDirection>,
) -> bool
fn hit_test( &self, size: Size, position: Offset, text_direction: Option<TextDirection>, ) -> bool
Source§fn create_box_painter(
&self,
on_changed: Option<Rc<dyn Fn(&mut App)>>,
) -> Box<dyn BoxPainter>
fn create_box_painter( &self, on_changed: Option<Rc<dyn Fn(&mut App)>>, ) -> Box<dyn BoxPainter>
BoxPainter that will paint this decoration.Source§fn eq_decoration(&self, other: &(dyn Decoration + 'static)) -> bool
fn eq_decoration(&self, other: &(dyn Decoration + 'static)) -> bool
== is identity; subclasses that override
== implement this.Source§fn diagnostics_node(&self, name: Option<String>) -> DiagnosticableNode
fn diagnostics_node(&self, name: Option<String>) -> DiagnosticableNode
Decoration.toDiagnosticsNode(name:), inherited from Diagnosticable; a
dyn Decoration cannot name the Sized Diagnosticable, so the bridge lives here.Source§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
Decoration.toStringShort: the runtime type.Source§impl Default for BoxDecoration
impl Default for BoxDecoration
Source§fn default() -> BoxDecoration
fn default() -> BoxDecoration
Source§impl Diagnosticable for BoxDecoration
impl Diagnosticable for BoxDecoration
Source§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
Source§fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Object.runtimeType as diagnostics print it: the last segment of
the Rust type path, without generic arguments.Source§fn identity_hash(&self) -> u64
fn identity_hash(&self) -> u64
Object.hashCode as diagnostics print it: the object’s address.Source§fn to_diagnostics_node(&self) -> DiagnosticableNode
fn to_diagnostics_node(&self) -> DiagnosticableNode
DiagnosticsNode::to_string_deep.Source§fn to_diagnostics_node_with(
&self,
name: Option<String>,
style: Option<DiagnosticsTreeStyle>,
) -> DiagnosticableNode
fn to_diagnostics_node_with( &self, name: Option<String>, style: Option<DiagnosticsTreeStyle>, ) -> DiagnosticableNode
toDiagnosticsNode(name:, style:).Source§fn to_string(&self) -> String
fn to_string(&self) -> String
toString: a single-line description with properties and no
children. Read moreSource§fn to_string_at(&self, min_level: DiagnosticLevel) -> String
fn to_string_at(&self, min_level: DiagnosticLevel) -> String
toString(minLevel:).