dimensions property Null safety

EdgeInsetsGeometry dimensions
override

The widths of the sides of this border represented as an EdgeInsets.

Specifically, this is the amount by which a rectangle should be inset so as to avoid painting over any important part of the border. It is the amount by which additional borders will be inset before they are drawn.

This can be used, for example, with a Padding widget to inset a box by the size of these borders.

Shapes that have a fixed ratio regardless of the area on which they are painted, or that change their rendering based on the size they are given when painting (for instance CircleBorder), will not return valid dimensions information because they cannot know their eventual size when computing their dimensions.

Implementation

@override
EdgeInsetsGeometry get dimensions {
  if (isUniform) {
    switch (top.strokeAlign) {
      case StrokeAlign.inside:
        return EdgeInsetsDirectional.all(top.width);
      case StrokeAlign.center:
        return EdgeInsetsDirectional.all(top.width / 2);
      case StrokeAlign.outside:
        return EdgeInsetsDirectional.zero;
    }
  }
  return EdgeInsetsDirectional.fromSTEB(start.width, top.width, end.width, bottom.width);
}