Skip to content

[Request] Add strokeAlign (inside/center/outside) to Border #88621

@bernaferrari

Description

@bernaferrari

Right now, Flutter only supports "inside" border in Border (source below). This is kind of frustrating as Figma has inside/center/outside options and it is not completely trivial to map them into Flutter. For outside many people use shadows, which is non-obvious.

I believe life could be easier if Border already supported this. It seems to me that the change wouldn't be big:

  1. Update the paint methods.
  2. Make the new constructor.
  3. Make new tests.

Possibly the code that needs to be updated:

canvas.drawRect(rect.deflate(width / 2.0), paint);

The implementation of something like this outside 'ring' seems too hard right now:
image

Sample code of the desired API.

enum StrokeAlign {
    inside,
    center,
    outside,
}

// option A
factory Border.all({
    Color color = const Color(0xFF000000),
    double width = 1.0,
    BorderStyle style = BorderStyle.solid,
    StrokeAlign strokeAlign = StrokeAlign.center,
});

//  option B
const BorderSide({
    this.color = const Color(0xFF000000),
    this.width = 1.0,
    this.style = BorderStyle.solid,
    this.strokeAlign = StrokeAlign.center,
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions