Commit 80ee2ff0 authored by 神楽坂花火's avatar 神楽坂花火 Committed by Flutter GitHub Bot

Add `Border.symmetric` constructor (#47523)

parent 7fee0c52
......@@ -326,6 +326,19 @@ class Border extends BoxBorder {
bottom = side,
left = side;
/// Creates a border with symmetrical vertical and horizontal sides.
///
/// All arguments default to [BorderSide.none] and must not be null.
const Border.symmetric({
BorderSide vertical = BorderSide.none,
BorderSide horizontal = BorderSide.none,
}) : assert(vertical != null),
assert(horizontal != null),
left = horizontal,
top = vertical,
right = horizontal,
bottom = vertical;
/// A uniform border with all sides the same color and width.
///
/// The sides default to black solid borders, one logical pixel wide.
......
......@@ -23,6 +23,18 @@ void main() {
expect(border.bottom, same(side));
});
test('Border.symmetric constructor', () {
expect(() => Border.symmetric(vertical: nonconst(null)), throwsAssertionError);
expect(() => Border.symmetric(horizontal: nonconst(null)), throwsAssertionError);
const BorderSide side1 = BorderSide(color: Color(0xFFFFFFFF));
const BorderSide side2 = BorderSide(color: Color(0xFF000000));
const Border border = Border.symmetric(vertical: side1, horizontal: side2);
expect(border.left, same(side2));
expect(border.top, same(side1));
expect(border.right, same(side2));
expect(border.bottom, same(side1));
});
test('Border.merge', () {
const BorderSide magenta3 = BorderSide(color: Color(0xFFFF00FF), width: 3.0);
const BorderSide magenta6 = BorderSide(color: Color(0xFFFF00FF), width: 6.0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment