DecoratedBox class

A widget that paints a background decoration and border around a child widget.

Shrinks the child's rendering viewport by the width of the active borders so the child does not overlap with the border lines.

Example Usage

DecoratedBox(
  decoration: BoxDecoration(
    border: Border.doubleLine,
  ),
  child: Text('Content inside a double-bordered box'),
);

Properties

Property Type Description
decoration BoxDecoration Visual border and background layout settings.
child Widget The nested child widget to render inside the box.
Inheritance

Constructors

DecoratedBox({required BoxDecoration decoration, required Widget child})
Creates a DecoratedBox with the given decoration and child.
const

Properties

child Widget
The nested child widget to render inside the box.
final
decoration BoxDecoration
Visual border and background layout settings.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
The optional key for this widget.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() Element
Creates an Element to manage this widget's location in the tree.
override
getIntrinsicHeight(int width) int
Computes the intrinsic height of this widget under the given width constraint.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
render(Buffer buffer, Rect area) → void
Renders the widget onto the provided buffer within the specified area.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited