Skip to content

Conversation

@HansMuller
Copy link
Contributor

@HansMuller HansMuller commented May 5, 2020

Defined a new OutlinedBorder abstract class in between ShapeBorder and the existing concrete subclasses like RoundedRectangleBorder. OutlinedBorder adds a BorderSide property and a copyWith method with the usual semantics. That makes it possible to combine an OutlinedBorder that defines a component's shape, with a BorderSide that defines how the border outline is to appear.

For example:

RoundedRectangleBorder().copyWith(
  side: BorderSide(color: Colors.green, width: 3),
)

BeveledRectangleBorder, CircleBorder, ContinuousRectangleBorder, RoundedRectangleBorder, and StadiumBorder are now OutlinedBorders.

This PR does not update the existing InputBorder class to be an OutlinedBorder. InputBorder's BorderSide property and constructor parameter is called "borderSide"; other than that, the two classes are compatible. A future PR could make InputBorder an OutlinedBorder however, that would be a breaking change.

@Hixie
Copy link
Contributor

Hixie commented May 5, 2020

I don't think we should do this. There's no reason why a border needs to support a BorderSide. It could have many, it could have none. We could have a subclass of ShapeBorder, ShapeBorderWithSide or something, that the others inherit from if we want to do this, but fundamentally the core type shouldn't have to know about sides IMHO.

Having the default not do anything, in particular, seems like a confusing API.

That said, what's the use case?

@HansMuller
Copy link
Contributor Author

HansMuller commented May 5, 2020

The use case I'm concerned about at the moment is enabling one to specify a button's shape separately from the outline that decorates its border. An app theme needs to be able to specify the shape of buttons (or other components) without disturbing the outline (if any) that the buttons decorate their border with. Similarly, a theme should be able to specify a button's border decoration, independently of its shape.

@Hixie
Copy link
Contributor

Hixie commented May 5, 2020

We could have an OutlineableShape class that is between ShapeBorder and those subclasses that have a side, and the button theming could require that it be used, while allowing other widgets to use the regular ShapeBorder. We have precedent for that, e. g. IIRC the text fields require a particular shape subclass.

@HansMuller
Copy link
Contributor Author

Yes, that sounds reasonable although "outlineable" stretches our common language. It's a shame that we can't have Shape and BorderedShape but those ships have sailed (and "BorderedShapeBorder" is terrible). Maybe OutlinedShape?

@HansMuller HansMuller changed the title Add ShapeBorder.withSide(BorderSide side) Add OutlinedBorder class May 7, 2020
Copy link
Contributor

@Hixie Hixie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great.
LGTM

@fluttergithubbot fluttergithubbot merged commit 26dc70d into flutter:master May 8, 2020
@HansMuller HansMuller deleted the shaped_border_with_side branch May 8, 2020 01:22
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants