Use toStringAsFixed in DecorationImage.toString (#131026)
This makes the output less sensitive on JS int vs double shenanigans.
diff --git a/packages/flutter/lib/src/painting/decoration_image.dart b/packages/flutter/lib/src/painting/decoration_image.dart
index 87ed9e0..5c8ed9d 100644
--- a/packages/flutter/lib/src/painting/decoration_image.dart
+++ b/packages/flutter/lib/src/painting/decoration_image.dart
@@ -236,8 +236,8 @@
'$repeat',
if (matchTextDirection)
'match text direction',
- 'scale $scale',
- 'opacity $opacity',
+ 'scale ${scale.toStringAsFixed(1)}',
+ 'opacity ${opacity.toStringAsFixed(1)}',
'$filterQuality',
if (invertColors)
'invert colors',
diff --git a/packages/flutter/test/painting/decoration_test.dart b/packages/flutter/test/painting/decoration_test.dart
index 649acd1..8750ba5 100644
--- a/packages/flutter/test/painting/decoration_test.dart
+++ b/packages/flutter/test/painting/decoration_test.dart
@@ -333,6 +333,19 @@
expect(paint.invertColors, !kIsWeb);
});
+ test('DecorationImage.toString', () async {
+ expect(
+ DecorationImage(
+ image: SynchronousTestImageProvider(
+ await createTestImage(width: 100, height: 100),
+ ),
+ opacity: 0.99,
+ scale: 2.01,
+ ).toString(),
+ 'DecorationImage(SynchronousTestImageProvider(), Alignment.center, scale 2.0, opacity 1.0, FilterQuality.low)',
+ );
+ });
+
test('DecorationImage with null textDirection configuration should throw Error', () async {
const ColorFilter colorFilter = ui.ColorFilter.mode(Color(0xFF00FF00), BlendMode.src);
final ui.Image image = await createTestImage(width: 100, height: 100);