@@ -198,9 +198,18 @@ abstract class Decoration with Diagnosticable {
198
198
/// happens, the [onChanged] callback will be invoked. To stop this callback
199
199
/// from being called after the painter has been discarded, call [dispose] .
200
200
abstract 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
+ }
204
213
205
214
/// Paints the [Decoration] for which this object was created on the
206
215
/// given canvas using the given configuration.
@@ -243,5 +252,9 @@ abstract class BoxPainter {
243
252
/// The [onChanged] callback will not be invoked after this method has been
244
253
/// called.
245
254
@mustCallSuper
246
- void dispose () { }
255
+ void dispose () {
256
+ if (kFlutterMemoryAllocationsEnabled) {
257
+ FlutterMemoryAllocations .instance.dispatchObjectDisposed (object: this );
258
+ }
259
+ }
247
260
}
0 commit comments