pub struct DecoratedBox {
pub key: Option<KeyRef>,
pub decoration: DecorationRef,
pub position: DecorationPosition,
pub child: Option<WidgetRef>,
}Expand description
A widget that paints a [Decoration] either before or after its child paints.
Container insets its child by the widths of the borders; this widget does
not.
Commonly used with BoxDecoration.
The child is not clipped. To clip a child to the shape of a particular
ShapeDecoration, consider using a ClipPath widget.
This sample shows a radial gradient that draws a moon on a night sky:
DecoratedBox {
decoration: Box::new(BoxDecoration::new().gradient(RadialGradient { .. })),
..
}See also:
Ink, which paints a [Decoration] on aMaterial, allowingInkResponseandInkWellsplashes to paint over them.DecoratedSliver, which applies a [Decoration] to a sliver.DecoratedBoxTransition, the version of this class that animates on thedecoration.- [
Decoration], which you can extend to provide other effects withDecoratedBox. CustomPaint, another way to draw custom effects from the widget layer.
Flutter home: widgets/container.dart.
Fields§
§key: Option<KeyRef>§decoration: DecorationRefWhat decoration to paint.
Commonly a BoxDecoration.
position: DecorationPositionWhether to paint the box decoration behind or in front of the child.
By default the decoration paints behind the child.
child: Option<WidgetRef>Implementations§
Source§impl DecoratedBox
impl DecoratedBox
Sourcepub fn new(decoration: impl Into<DecorationRef>) -> DecoratedBox
pub fn new(decoration: impl Into<DecorationRef>) -> DecoratedBox
Creates a DecoratedBox; Dart’s optional named arguments are the setters.
Sourcepub fn key(self, key: KeyRef) -> DecoratedBox
pub fn key(self, key: KeyRef) -> DecoratedBox
Dart DecoratedBox(key:).
Sourcepub fn position(self, position: DecorationPosition) -> DecoratedBox
pub fn position(self, position: DecorationPosition) -> DecoratedBox
Dart DecoratedBox(position:).
Sourcepub fn child<K>(self, child: impl IntoWidget<K>) -> DecoratedBox
pub fn child<K>(self, child: impl IntoWidget<K>) -> DecoratedBox
Dart DecoratedBox(child:).
Trait Implementations§
Source§impl Debug for DecoratedBox
impl Debug for DecoratedBox
Source§impl RenderObjectWidget for DecoratedBox
impl RenderObjectWidget for DecoratedBox
Source§type RenderObject = RenderDecoratedBox
type RenderObject = RenderDecoratedBox
The render object this widget creates; Dart’s
covariant RenderObject parameter type.Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
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 create_render_object(
&self,
app: &mut App,
context: BuildContext,
) -> AnyRenderObject
fn create_render_object( &self, app: &mut App, context: BuildContext, ) -> AnyRenderObject
Creates an instance of the
RenderObject class that this widget represents, using the
configuration described by this widget. Read moreSource§fn update_render_object(
&self,
app: &mut App,
context: BuildContext,
render_object: RenderHandle<RenderDecoratedBox>,
)
fn update_render_object( &self, app: &mut App, context: BuildContext, render_object: RenderHandle<RenderDecoratedBox>, )
Copies the configuration described by this widget to the given render object, which
will be of the same type as returned by this object’s
create_render_object. Read moreSource§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
Dart’s
toStringShort, for a widget that names itself apart from its type, as
SizedBox.expand does; see Widget::to_string_short.Source§fn debug_visit_onstage_children(
&self,
app: &App,
children: &[AnyElement],
visitor: &mut dyn FnMut(AnyElement),
)
fn debug_visit_onstage_children( &self, app: &App, children: &[AnyElement], visitor: &mut dyn FnMut(AnyElement), )
Dart’s
debugVisitOnstageChildren of the element this widget makes, for a widget whose
Dart element subclass overrides it only to hide children (_OffstageElement,
_IndexedStackElement): calls visitor for each of children, in order, that is
onstage. Waft’s generic single- and multi-child elements stand in for those subclasses
and ask their widget here; an element of a widget’s own overrides
Element::debug_visit_onstage_children instead.Source§fn did_unmount_render_object(
&self,
app: &mut App,
render_object: RenderHandle<Self::RenderObject>,
)
fn did_unmount_render_object( &self, app: &mut App, render_object: RenderHandle<Self::RenderObject>, )
A render object previously associated with this widget has been removed from the tree.
The given
RenderObject will be of the same type as returned by this object’s
create_render_object.Auto Trait Implementations§
impl !RefUnwindSafe for DecoratedBox
impl !Send for DecoratedBox
impl !Sync for DecoratedBox
impl !UnwindSafe for DecoratedBox
impl Forget for DecoratedBox
impl Freeze for DecoratedBoxwhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const RcInner<dyn Decoration> is !null: Freeze,
PhantomData<RcInner<dyn Decoration>>: Freeze,
*const RcInner<dyn Widget> is !null: Freeze,
PhantomData<RcInner<dyn Widget>>: Freeze,
impl Move for DecoratedBox
impl Unpin for DecoratedBox
impl UnsafeUnpin for DecoratedBoxwhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const RcInner<dyn Decoration> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Decoration>>: 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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<SingleChildRenderObjectKind> for Wwhere
W: SingleChildRenderObjectWidget,
<W as RenderObjectWidget>::RenderObject: RenderObjectWithChildMixin,
impl<W> IntoWidget<SingleChildRenderObjectKind> for Wwhere
W: SingleChildRenderObjectWidget,
<W as RenderObjectWidget>::RenderObject: RenderObjectWithChildMixin,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
The widget as a tree node, made where this is called: its
creation_location.