Skip to content

Commit 8a01c9b

Browse files
authored
Use toStringAsFixed in DecorationImage.toString (flutter#131026)
This makes the output less sensitive on JS int vs double shenanigans.
1 parent c53cfc5 commit 8a01c9b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/flutter/lib/src/painting/decoration_image.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ class DecorationImage {
236236
'$repeat',
237237
if (matchTextDirection)
238238
'match text direction',
239-
'scale $scale',
240-
'opacity $opacity',
239+
'scale ${scale.toStringAsFixed(1)}',
240+
'opacity ${opacity.toStringAsFixed(1)}',
241241
'$filterQuality',
242242
if (invertColors)
243243
'invert colors',

packages/flutter/test/painting/decoration_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,19 @@ void main() {
333333
expect(paint.invertColors, !kIsWeb);
334334
});
335335

336+
test('DecorationImage.toString', () async {
337+
expect(
338+
DecorationImage(
339+
image: SynchronousTestImageProvider(
340+
await createTestImage(width: 100, height: 100),
341+
),
342+
opacity: 0.99,
343+
scale: 2.01,
344+
).toString(),
345+
'DecorationImage(SynchronousTestImageProvider(), Alignment.center, scale 2.0, opacity 1.0, FilterQuality.low)',
346+
);
347+
});
348+
336349
test('DecorationImage with null textDirection configuration should throw Error', () async {
337350
const ColorFilter colorFilter = ui.ColorFilter.mode(Color(0xFF00FF00), BlendMode.src);
338351
final ui.Image image = await createTestImage(width: 100, height: 100);

0 commit comments

Comments
 (0)