Add Border.symmetric
constructor (#47523)
This commit is contained in:
parent
7fee0c52d3
commit
80ee2ff04f
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user