Box class

This is a generic widget for low level layout needs. It is similar to a Container in Material Widget.

Box Widget is used to display its child with many decoration around it.

Example

An basic example of the Box widget

 Box(
   p: '2',
   color: 'cyan.500',
   shadow: '2',
   child: NBText(
     text: "This is Box",
     fontSize: 'md',
     fontWeight: 'medium',
     letterSpacing: 'lg',
     color: 'warmGray.100',
   ),
 )

Box with customized border width , border color and border radius See the list of properties of Box for more example An example of the Box widget with borders and border radius

 Box(
  p: '2',
  color: 'cyan.500',
  shadow: '2',
  borderWidth: '2',
  borderColor: 'pink',
  borderRadius: 'full',
  child: NBText(
    text: "This is Box",
    fontSize: 'md',
    fontWeight: 'medium',
    letterSpacing: 'lg',
    color: 'warmGray.100',
  ),
)
Inheritance
Implemented types
Implementers

Constructors

Box({String? alignment, String? color, String? bgImage, String? shadow, String? borderWidth, String? borderLeft, String? borderRight, String? borderTop, String? borderBottom, String? borderStyle, String? borderColor, String? borderRadius, String? borderBottomLeftRadius, String? borderBottomRightRadius, String? borderTopLeftRadius, String? borderTopRightRadius, String? borderLeftRadius, String? borderRightRadius, String? borderTopRadius, String? borderBottomRadius, String? h, String? w, String? maxW, String? maxH, String? minH, String? minW, String? m, String? mt, String? mr, String? mb, String? ml, String? mx, String? my, String? p, String? pt, String? pr, String? pb, String? pl, String? px, String? py, Key? key, LinearGradient? gradient, Widget? child, String? height, String? width})
const

Properties

alignment String?
The Box child alignment will be set using alignment. Use nativebase alignment tokens as string like wise
final
bgImage String?
Sets the background image of the box
final
borderBottom String?
Sets the bottom border width of the box.
final
borderBottomLeftRadius String?
Sets the Radius of bottom right corner of the box.
final
borderBottomRadius String?
Sets the Radius of bottom right and left corner of the box.
final
borderBottomRightRadius String?
Sets the Radius of bottom right corner of the box.
final
borderColor String?
Sets the border color of the box.
final
borderLeft String?
Sets the right border width of the box.
final
borderLeftRadius String?
Sets the Radius of left top and bottom corner of the box.
final
borderRadius String?
Sets the corner Radius of the box.
final
borderRight String?
Sets the right border width of the box.
final
borderRightRadius String?
Sets the Radius of right top and bottom corner of the box.
final
borderStyle String?
Sets the border color of the box.
final
borderTop String?
Sets the top border width of the box.
final
borderTopLeftRadius String?
Sets the Radius of top left corner of the box.
final
borderTopRadius String?
Sets the Radius of top right and left corner of the box.
final
borderTopRightRadius String?
Sets the Radius of top right corner of the box.
final
borderWidth String?
Sets the border width of the box from all the side.
final
child Widget?
Sets child to the box
final
color String?
The Box background color. Use nativebase color tokens as string like wise
final
gradient LinearGradient?
Sets linearGradient to the box
final
h String?
Sets the box height
final
hashCode int
The hash code for this object.
no setterinherited
height String?
Sets the box height
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
m String?
Sets the box margin from all the side of box
final
maxH String?
Sets the max height of the box
final
maxW String?
Sets the max width of the box
final
mb String?
Sets the box margin from bottom
final
minH String?
Sets the min height of the box
final
minW String?
Sets the min width of the box
final
ml String?
Sets the box margin from left
final
mr String?
Sets the box margin from right
final
mt String?
Sets the box margin from top
final
mx String?
Sets the box margin on X-Axis
final
my String?
Sets the box margin on Y-Axis
final
p String?
Sets the box padding from all the side
final
pb String?
Sets the box padding from bottom
final
pl String?
Sets the box padding from left
final
pr String?
Sets the box padding from right
final
pt String?
Sets the box padding from top
final
px String?
Sets the box padding on X-Axis
final
py String?
Sets the box padding on Y-Axis
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shadow String?
The Box elevation shadow. Use nativebase shadow tokens as string like wise
final
w String?
Sets the box width
final
width String?
Sets the box height
final

Methods

build(BuildContext context) Widget
Build method is responsible for building the entire widget by using the resolvers
inherited
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolveComponentLevelTheme(BuildContext context, Map<String, dynamic> styles, {String? component}) Map<String, dynamic>
inherited
resolveProps({required Map<String, dynamic> resolvedTokens}) Map<String, dynamic>
inherited
resolveTokens({required Map<String, dynamic> toJson, required BuildContext context, Component? component}) Map<String, dynamic>
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toJson() Map<String, dynamic>
Holds the override implementation of the widget to get json format of the widget class
override
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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