use textdirection for gradient of ShapeDecoration (#77186)

This commit is contained in:
Michael Goderbauer
2021-03-03 17:39:03 -08:00
committed by GitHub
parent 6c062894f0
commit effa7d5280
2 changed files with 27 additions and 1 deletions

View File

@@ -329,7 +329,7 @@ class _ShapeDecorationPainter extends BoxPainter {
_interiorPaint!.color = _decoration.color!;
}
if (_decoration.gradient != null)
_interiorPaint!.shader = _decoration.gradient!.createShader(rect);
_interiorPaint!.shader = _decoration.gradient!.createShader(rect, textDirection: textDirection);
if (_decoration.shadows != null) {
if (_shadowCount == null) {
_shadowCount = _decoration.shadows!.length;

View File

@@ -114,6 +114,32 @@ Future<void> main() async {
);
});
testWidgets('Does not crash with directional gradient', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/76967.
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.rtl,
child: DecoratedBox(
decoration: ShapeDecoration(
gradient: RadialGradient(
focal: AlignmentDirectional(0, 1),
focalRadius: 5,
radius: 2,
colors: <Color>[Colors.red, Colors.black],
stops: <double>[0.0, 0.4],
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8.0)),
),
),
),
),
);
expect(tester.takeException(), isNull);
});
test('ShapeDecoration equality', () {
const ShapeDecoration a = ShapeDecoration(
color: Color(0xFFFFFFFF),