Revert "Remove support for `Paint.enableDithering=false` in `dart:ui`. (#46745)"

This reverts commit 80868149792f17707f6dea5d54874332a7b3b02d.
diff --git a/flutter_frontend_server/test/to_string_test.dart b/flutter_frontend_server/test/to_string_test.dart
index ded3b98..53957fd 100644
--- a/flutter_frontend_server/test/to_string_test.dart
+++ b/flutter_frontend_server/test/to_string_test.dart
@@ -45,7 +45,9 @@
     ]));
     final ProcessResult runResult = Process.runSync(dart, <String>[regularDill]);
     checkProcessResult(runResult);
-    String paintString = '"Paint.toString":"Paint(Color(0xffffffff))"';
+    // TODO(matanlurey): "dither: true" is now present by default, until it is
+    // remove entirely. See https://github.com/flutter/flutter/issues/112498.
+    String paintString = '"Paint.toString":"Paint(Color(0xffffffff); dither: true)"';
     if (buildDir.contains('release')) {
       paintString = '"Paint.toString":"Instance of \'Paint\'"';
     }
diff --git a/lib/ui/painting.dart b/lib/ui/painting.dart
index cfb5e23..638a257 100644
--- a/lib/ui/painting.dart
+++ b/lib/ui/painting.dart
@@ -1091,8 +1091,9 @@
   /// Constructs an empty [Paint] object with all fields initialized to
   /// their defaults.
   Paint() {
-    // TODO(matanlurey): Remove as part of https://github.com/flutter/flutter/issues/112498.
-    _enableDithering();
+    if (enableDithering) {
+      _dither = true;
+    }
   }
 
   // Paint objects are encoded in two buffers:
@@ -1478,10 +1479,26 @@
     _data.setInt32(_kInvertColorOffset, value ? 1 : 0, _kFakeHostEndian);
   }
 
-  // TODO(matanlurey): Remove as part of https://github.com/flutter/flutter/issues/112498.
-  void _enableDithering() {
-    _data.setInt32(_kDitherOffset, 1, _kFakeHostEndian);
+  bool get _dither {
+    return _data.getInt32(_kDitherOffset, _kFakeHostEndian) == 1;
   }
+  set _dither(bool value) {
+    _data.setInt32(_kDitherOffset, value ? 1 : 0, _kFakeHostEndian);
+  }
+
+  /// Whether to dither the output when drawing some elements such as gradients.
+  ///
+  /// It is not expected that this flag will be used in the future; please leave
+  /// feedback in <https://github.com/flutter/flutter/issues/112498> if there is
+  /// a use case for this flag to remain long term.
+  @Deprecated(
+    'Dithering is now enabled by default on some elements (such as gradients) '
+    'and further support for dithering is expected to be handled by custom '
+    'shaders, so this flag is being removed: '
+    'https://github.com/flutter/flutter/issues/112498.'
+    'This feature was deprecated after 3.14.0-0.1.pre.'
+  )
+  static bool enableDithering = true;
 
   @override
   String toString() {
@@ -1545,6 +1562,9 @@
     if (invertColors) {
       result.write('${semicolon}invert: $invertColors');
     }
+    if (_dither) {
+      result.write('${semicolon}dither: $_dither');
+    }
     result.write(')');
     return result.toString();
   }
diff --git a/lib/web_ui/lib/painting.dart b/lib/web_ui/lib/painting.dart
index c050e43..026f20b 100644
--- a/lib/web_ui/lib/painting.dart
+++ b/lib/web_ui/lib/painting.dart
@@ -217,6 +217,7 @@
 
 abstract class Paint {
   factory Paint() => engine.renderer.createPaint();
+  static bool enableDithering = false;
   BlendMode get blendMode;
   set blendMode(BlendMode value);
   PaintingStyle get style;
diff --git a/testing/dart/canvas_test.dart b/testing/dart/canvas_test.dart
index 6732423..716233f 100644
--- a/testing/dart/canvas_test.dart
+++ b/testing/dart/canvas_test.dart
@@ -202,7 +202,28 @@
     );
   }
 
-  test('Simple gradient, which is implicitly dithered', () async {
+  test('Simple gradient', () async {
+    // TODO(matanl): While deprecated, we still don't want to accidentally
+    // change the behavior of the old API,
+    // https://github.com/flutter/flutter/issues/112498.
+    // ignore: deprecated_member_use
+    Paint.enableDithering = false;
+    final Image image = await toImage((Canvas canvas) {
+      final Paint paint = Paint()..shader = makeGradient();
+      canvas.drawPaint(paint);
+    }, 100, 100);
+    expect(image.width, equals(100));
+    expect(image.height, equals(100));
+
+    final bool areEqual =
+        await fuzzyGoldenImageCompare(image, 'canvas_test_gradient.png');
+    expect(areEqual, true);
+  }, skip: !Platform.isLinux); // https://github.com/flutter/flutter/issues/53784
+
+  test('Simple dithered gradient', () async {
+    // TODO(matanl): Reword this test once we remove the deprecated API.
+    // ignore: deprecated_member_use
+    Paint.enableDithering = true;
     final Image image = await toImage((Canvas canvas) {
       final Paint paint = Paint()..shader = makeGradient();
       canvas.drawPaint(paint);