@@ -198,9 +198,18 @@ abstract class Decoration with Diagnosticable {
198198/// happens, the [onChanged] callback will be invoked. To stop this callback
199199/// from being called after the painter has been discarded, call [dispose] .
200200abstract class BoxPainter {
201- /// Abstract const constructor. This constructor enables subclasses to provide
202- /// const constructors so that they can be used in const expressions.
203- const BoxPainter ([this .onChanged]);
201+ /// Default abstract constructor for box painters.
202+ BoxPainter ([this .onChanged]) {
203+ // TODO(polina-c): stop duplicating code across disposables
204+ // https://github.com/flutter/flutter/issues/137435
205+ if (kFlutterMemoryAllocationsEnabled) {
206+ FlutterMemoryAllocations .instance.dispatchObjectCreated (
207+ library: 'package:flutter/painting.dart' ,
208+ className: '$BoxPainter ' ,
209+ object: this ,
210+ );
211+ }
212+ }
204213
205214 /// Paints the [Decoration] for which this object was created on the
206215 /// given canvas using the given configuration.
@@ -243,5 +252,9 @@ abstract class BoxPainter {
243252 /// The [onChanged] callback will not be invoked after this method has been
244253 /// called.
245254 @mustCallSuper
246- void dispose () { }
255+ void dispose () {
256+ if (kFlutterMemoryAllocationsEnabled) {
257+ FlutterMemoryAllocations .instance.dispatchObjectDisposed (object: this );
258+ }
259+ }
247260}
0 commit comments