SnapshotPainter should dispatch creation and disposal events. (#138810)

diff --git a/packages/flutter/lib/src/widgets/snapshot_widget.dart b/packages/flutter/lib/src/widgets/snapshot_widget.dart
index c680d58..193616f 100644
--- a/packages/flutter/lib/src/widgets/snapshot_widget.dart
+++ b/packages/flutter/lib/src/widgets/snapshot_widget.dart
@@ -4,6 +4,7 @@
 
 import 'dart:ui' as ui;
 
+import 'package:flutter/foundation.dart';
 import 'package:flutter/rendering.dart';
 
 import 'basic.dart';
@@ -385,7 +386,14 @@
 /// }
 /// ```
 /// {@end-tool}
-abstract class SnapshotPainter extends ChangeNotifier  {
+abstract class SnapshotPainter extends ChangeNotifier {
+  /// Creates an instance of [SnapshotPainter].
+  SnapshotPainter() {
+    if (kFlutterMemoryAllocationsEnabled) {
+      ChangeNotifier.maybeDispatchObjectCreation(this);
+    }
+  }
+
   /// Called whenever the [image] that represents a [SnapshotWidget]s child should be painted.
   ///
   /// The image is rasterized at the physical pixel resolution and should be scaled down by
diff --git a/packages/flutter/test/widgets/snapshot_widget_test.dart b/packages/flutter/test/widgets/snapshot_widget_test.dart
index 7bc8cd7..7d6df8b 100644
--- a/packages/flutter/test/widgets/snapshot_widget_test.dart
+++ b/packages/flutter/test/widgets/snapshot_widget_test.dart
@@ -326,6 +326,16 @@
     await expectLater(find.byKey(repaintBoundaryKey), matchesReferenceImage(imageWhenDisabled));
   },
   skip: kIsWeb); // TODO(jonahwilliams): https://github.com/flutter/flutter/issues/106689
+
+  test('SnapshotPainter dispatches memory events', () async {
+    await expectLater(
+      await memoryEvents(
+        () => TestPainter().dispose(),
+        TestPainter,
+      ),
+      areCreateAndDispose,
+    );
+  });
 }
 
 class TestPlatformView extends SingleChildRenderObjectWidget {