BorderSide class
A side of a border of a box.
A Border consists of four BorderSide objects: Border.top, Border.left, Border.right, and Border.bottom.
Setting BorderSide.width to 0.0 will result in hairline rendering; see BorderSide.width for a more involved explanation.
This sample shows how BorderSide objects can be used in a Container, via
a BoxDecoration and a Border, to decorate some Text. In this example,
the text has a thick bar above it that is light blue, and a thick bar below
it that is a darker shade of blue.
link
Container(
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
border: Border(
top: BorderSide(width: 16.0, color: Colors.lightBlue.shade50),
bottom: BorderSide(width: 16.0, color: Colors.lightBlue.shade900),
),
),
child: const Text('Flutter in the sky', textAlign: TextAlign.center),
)
See also:
- Border, which uses BorderSide objects to represent its sides.
- BoxDecoration, which optionally takes a Border object.
- TableBorder, which is similar to Border but has two more sides (TableBorder.horizontalInside and TableBorder.verticalInside), both of which are also BorderSide objects.
- Mixed in types
- Implementers
- Annotations
Constructors
- BorderSide({Color color = const Color(0xFF000000), double width = 1.0, BorderStyle style = BorderStyle.solid, double strokeAlign = strokeAlignInside})
-
Creates the side of a border.
const
Properties
- color → Color
-
The color of this side of the border.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- strokeAlign → double
-
The relative position of the stroke on a BorderSide in an
OutlinedBorder or Border.
final
- strokeInset → double
-
Get the amount of the stroke width that lies inside of the BorderSide.
no setter
- strokeOffset → double
-
The offset of the stroke, taking into account the stroke alignment.
no setter
- strokeOutset → double
-
Get the amount of the stroke width that lies outside of the BorderSide.
no setter
- style → BorderStyle
-
The style of this side of the border.
final
- width → double
-
The width of this side of the border, in logical pixels.
final
Methods
-
copyWith(
{Color? color, double? width, BorderStyle? style, double? strokeAlign}) → BorderSide - Creates a copy of this border but with the given fields replaced with the new values.
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
scale(
double t) → BorderSide -
Creates a copy of this border side description but with the width scaled
by the factor
t
. -
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toPaint(
) → Paint - Create a Paint object that, if used to stroke a line, will draw the line in this border's style.
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringShort(
) → String -
A brief description of this object, usually just the runtimeType and the
hashCode.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Methods
-
canMerge(
BorderSide a, BorderSide b) → bool - Whether the two given BorderSides can be merged using BorderSide.merge.
-
lerp(
BorderSide a, BorderSide b, double t) → BorderSide - Linearly interpolate between two border sides.
-
merge(
BorderSide a, BorderSide b) → BorderSide - Creates a BorderSide that represents the addition of the two given BorderSides.
Constants
- none → const BorderSide
- A hairline black border that is not rendered.
- strokeAlignCenter → const double
- The border is drawn on the center of the border path, with half of the BorderSide.width on the inside, and the other half on the outside of the path.
- strokeAlignInside → const double
- The border is drawn fully inside of the border path.
- strokeAlignOutside → const double
- The border is drawn on the outside of the border path.