LinearBorder class

An OutlinedBorder like BoxBorder that allows one to define a rectangular (box) border in terms of zero to four LinearBorderEdges, each of which is rendered as a single line.

The color and width of each line are defined by side. When LinearBorder is used with a class whose border sides and shape are defined by a ButtonStyle, then a non-null ButtonStyle.side will override the one specified here. For example the LinearBorder in the TextButton example below adds a red underline to the button. This is because TextButton's side parameter overrides the side property of its ButtonStyle.shape.

 TextButton(
   style: TextButton.styleFrom(
     side: const BorderSide(color: Colors.red),
     shape: const LinearBorder(
       side: BorderSide(color: Colors.blue),
       bottom: LinearBorderEdge(),
     ),
   ),
   onPressed: () { },
   child: const Text('Red LinearBorder'),
 )

This class resolves itself against the current TextDirection (see Directionality). Start and end values resolve to left and right for TextDirection.ltr and to right and left for TextDirection.rtl.

Convenience constructors are included for the common case where just one edge is specified: LinearBorder.start, LinearBorder.end, LinearBorder.top, LinearBorder.bottom.

This example shows how to draw different kinds of LinearBorders.
link

To create a local project with this code sample, run:
flutter create --sample=painting.LinearBorder.1 mysample

Inheritance

Constructors

LinearBorder({BorderSide side = BorderSide.none, LinearBorderEdge? start, LinearBorderEdge? end, LinearBorderEdge? top, LinearBorderEdge? bottom})
Creates a rectangular box border that's rendered as zero to four lines.
const
LinearBorder.bottom({BorderSide side = BorderSide.none, double alignment = 0.0, double size = 1.0})
Creates a rectangular box border with an edge on the bottom.
LinearBorder.end({BorderSide side = BorderSide.none, double alignment = 0.0, double size = 1.0})
Creates a rectangular box border with an edge on the right for TextDirection.ltr or on the left for TextDirection.rtl.
LinearBorder.start({BorderSide side = BorderSide.none, double alignment = 0.0, double size = 1.0})
Creates a rectangular box border with an edge on the left for TextDirection.ltr or on the right for TextDirection.rtl.
LinearBorder.top({BorderSide side = BorderSide.none, double alignment = 0.0, double size = 1.0})
Creates a rectangular box border with an edge on the top.

Properties

bottom LinearBorderEdge?
Defines the bottom edge.
final
dimensions EdgeInsetsGeometry
The widths of the sides of this border represented as an EdgeInsets.
no setteroverride
end LinearBorderEdge?
Defines the right edge for TextDirection.ltr or the left for TextDirection.rtl.
final
hashCode int
The hash code for this object.
no setteroverride
preferPaintInterior bool
Reports whether paintInterior is implemented.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
side BorderSide
The border outline's color and weight.
finalinherited
start LinearBorderEdge?
Defines the left edge for TextDirection.ltr or the right for TextDirection.rtl.
final
top LinearBorderEdge?
Defines the top edge.
final

Methods

add(ShapeBorder other, {bool reversed = false}) ShapeBorder?
Attempts to create a new object that represents the amalgamation of this border and the other border.
inherited
copyWith({BorderSide? side, LinearBorderEdge? start, LinearBorderEdge? end, LinearBorderEdge? top, LinearBorderEdge? bottom}) LinearBorder
Returns a copy of this LinearBorder with the given fields replaced with the new values.
override
getInnerPath(Rect rect, {TextDirection? textDirection}) Path
Create a Path that describes the inner edge of the border.
override
getOuterPath(Rect rect, {TextDirection? textDirection}) Path
Create a Path that describes the outer edge of the border.
override
lerpFrom(ShapeBorder? a, double t) ShapeBorder?
Linearly interpolates from another ShapeBorder (possibly of another class) to this.
override
lerpTo(ShapeBorder? b, double t) ShapeBorder?
Linearly interpolates from this to another ShapeBorder (possibly of another class).
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
paint(Canvas canvas, Rect rect, {TextDirection? textDirection}) → void
Paints the border within the given Rect on the given Canvas.
override
paintInterior(Canvas canvas, Rect rect, Paint paint, {TextDirection? textDirection}) → void
Paint a canvas with the appropriate shape.
inherited
scale(double t) LinearBorder
Creates a copy of this border, scaled by the factor t.
override
toString() String
A string representation of this object.
override

Operators

operator +(ShapeBorder other) ShapeBorder
Creates a new border consisting of the two borders on either side of the operator.
inherited
operator ==(Object other) bool
The equality operator.
override

Constants

none → const LinearBorder
No border.