Unverified Commit b7046b32 authored by Bernardo Ferrari's avatar Bernardo Ferrari Committed by GitHub

Improve and optimize non-uniform Borders. (#124417)

~~Using the same priority order as a Border without borderRadius, it is possible to draw them on top of each other. This is better than the current behavior (crash!) and would work well for a "one color on top, another on bottom" scenario.~~

~~With this, if approved, we move the current number of possible exceptions from 4 to 1 (`BoxShape.circle` + `borderRadius`).~~

~~It is kind of odd how `borderRadius.zero` to `borderRadius != BorderRadius.zero` change, but I think it is better than crashing. Alternatively, we just remove the "original function" and see if any goldens are affected.~~

<img width="448" alt="image" src="https://user-images.githubusercontent.com/351125/236550350-7499d758-5b44-40e6-9105-32671eb21998.png">

Another one for @gspencergoog. If this works, we could make the paint method public and re-use in the InputBorder PR (if that's also approved). Single line fix.
parent fe9c7f4f
......@@ -1750,7 +1750,7 @@ void main() {
);
expect(
find.ancestor(of: find.byType(Table), matching: find.byType(Container)),
paints..drrect(color: borderColor),
paints..path(color: borderColor),
);
expect(
tester.getTopLeft(find.byType(Table)),
......
......@@ -136,8 +136,9 @@ void main() {
testWidgets('Vertical Divider Test 2', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Material(
MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Material(
child: SizedBox(
height: 24.0,
child: Row(
......
......@@ -273,7 +273,7 @@ void main() {
expect(error.diagnostics.length, 1);
expect(
error.diagnostics[0].toStringDeep(),
'A Border can only draw strokeAlign different than\nBorderSide.strokeAlignInside on borders with uniform colors and\nstyles.\n',
'A Border can only draw strokeAlign different than\nBorderSide.strokeAlignInside on borders with uniform colors.\n',
);
});
......@@ -341,8 +341,8 @@ void main() {
// This falls into non-uniform border because of strokeAlign.
await tester.pumpWidget(buildWidget(border: allowedBorderVariations));
expect(tester.takeException(), isNull,
reason: 'Border with non-uniform strokeAlign should not fail.');
expect(tester.takeException(), isAssertionError,
reason: 'Border with non-uniform strokeAlign should fail.');
await tester.pumpWidget(buildWidget(
border: allowedBorderVariations,
......@@ -364,8 +364,8 @@ void main() {
borderRadius: BorderRadius.circular(25),
),
);
expect(tester.takeException(), isAssertionError,
reason: 'Border with non-uniform styles should fail with borderRadius.');
expect(tester.takeException(), isNull,
reason: 'Border with non-uniform styles should work with borderRadius.');
await tester.pumpWidget(
buildWidget(
......@@ -381,6 +381,24 @@ void main() {
expect(tester.takeException(), isAssertionError,
reason: 'Border with non-uniform colors should fail with borderRadius.');
await tester.pumpWidget(
buildWidget(
border: const Border(bottom: BorderSide(width: 0)),
borderRadius: BorderRadius.zero,
),
);
expect(tester.takeException(), isNull,
reason: 'Border with a side.width == 0 should work without borderRadius (hairline border).');
await tester.pumpWidget(
buildWidget(
border: const Border(bottom: BorderSide(width: 0)),
borderRadius: BorderRadius.circular(40),
),
);
expect(tester.takeException(), isAssertionError,
reason: 'Border with width == 0 and borderRadius should fail (hairline border).');
// Tests for BorderDirectional.
const BorderDirectional allowedBorderDirectionalVariations = BorderDirectional(
start: BorderSide(width: 5),
......@@ -390,7 +408,7 @@ void main() {
);
await tester.pumpWidget(buildWidget(border: allowedBorderDirectionalVariations));
expect(tester.takeException(), isNull);
expect(tester.takeException(), isAssertionError);
await tester.pumpWidget(buildWidget(
border: allowedBorderDirectionalVariations,
......
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