Repository navigation
Closed
Labels
a: imagesLoading, displaying, rendering imagesLoading, displaying, rendering imagesc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutter
Description
Use case
Currently, Border has 3 constructors:
Borderfrom 4 (top, right, bottom, left)BorderSideBorder.fromBorderSidefrom singleBorderSidethat apply to all sides (top, right, bottom, left)Border.allfactory that internally instantiate aBorderSideand callBorder.fromBorderSide
I suggest a new factory constructor Border.symmetric.
A typical use case:
Container(
padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 2.0),
decoration: const BoxDecoration(
border: Border.symmetric(
horizontal: BorderSide(width: 1.0, color: Color(0xFFFFDFDFDF)),
vertical: BorderSide(width: 1.0, color: Color(0xFFFF7F7F7F)),
),
color: Color(0xFFBFBFBF),
),
)
Although it is rare for borders that is not in the same width or same color. It is convenient for widgets having only either horizontal or vertical border, in which is rather more common.
Proposal
factory Border.symmetric({ BorderSide vertical = BorderSide.none, BorderSide horizontal = BorderSide.none })
or
const Border.symmetric({ BorderSide vertical = BorderSide.none, BorderSide horizontal = BorderSide.none })
Reason for having factory of this name:
TableBorder is a class similar to Border and it has these constructors.
TableBorderfrom 6BorderSideTableBorderfactory that internally instantiate aBorderSideand call constructorTableBorder.symmetricfactory which accepts twoBorderSidefor inside and outside
Reason for having parameters of name:
EdgeInsets also handles top, right, bottom, left sides, has EdgeInsets.symmetric that accepts horizontal and vertical as parameter.
I can work a PR.
Metadata
Metadata
Assignees
Labels
a: imagesLoading, displaying, rendering imagesLoading, displaying, rendering imagesc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutter
Activity
github-actions commentedon Aug 24, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.