use textdirection for gradient of ShapeDecoration (#77186)
This commit is contained in:
committed by
GitHub
parent
6c062894f0
commit
effa7d5280
@@ -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;
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user