Unverified Commit 59956617 authored by Ferhat's avatar Ferhat Committed by GitHub

Fix outline button solid path when BorderSize.width is used (#51581)

parent a732652b
......@@ -561,7 +561,7 @@ class _OutlineBorder extends ShapeBorder implements MaterialStateProperty<ShapeB
case BorderStyle.none:
break;
case BorderStyle.solid:
canvas.drawPath(shape.getOuterPath(rect, textDirection: textDirection), side.toPaint());
canvas.drawPath(shape.getOuterPath(rect.deflate(side.width / 2.0), textDirection: textDirection), side.toPaint());
}
}
......
......@@ -867,6 +867,39 @@ void main() {
);
});
testWidgets('OutlineButton uses borderSide width to paint', (WidgetTester tester) async {
final GlobalKey buttonKey = GlobalKey();
const double thickness = 12.5;
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: Align(
alignment: Alignment.topLeft,
child: OutlineButton(
key: buttonKey,
borderSide: const BorderSide(
color: Colors.black12,
width: thickness),
onPressed: () {},
child: const SizedBox(
width: 120,
height: 50,
child: Text('ABC'),
),
),
),
),
),
);
final Finder outlineButton = find.byType(OutlineButton);
expect(outlineButton, paints..path(
includes: const <Offset>[Offset(60, thickness / 2.0)],
excludes: const <Offset>[Offset(60, thickness / 3.0)],
));
});
testWidgets('OutlineButton contributes semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
......
......@@ -1163,13 +1163,15 @@ class _PathPaintPredicate extends _DrawCommandPaintPredicate {
if (includes != null) {
for (final Offset offset in includes) {
if (!pathArgument.contains(offset))
throw 'It called $methodName with a path that unexpectedly did not contain $offset.';
throw 'It called $methodName with a path that unexpectedly did not '
'contain $offset. Path bounds = ${pathArgument.getBounds()}';
}
}
if (excludes != null) {
for (final Offset offset in excludes) {
if (pathArgument.contains(offset))
throw 'It called $methodName with a path that unexpectedly contained $offset.';
throw 'It called $methodName with a path that unexpectedly '
'contained $offset. . Path bounds = ${pathArgument.getBounds()}';
}
}
}
......
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