Skip to content

Commit 8e94423

Browse files
Reverts "BoxPainter should dispatch creation and disposal events." (#141545)
Reverts flutter/flutter#141526 Initiated by: CaseyHillers This change reverts the following previous change: Original Description: ### Description - Adds `BoxPainter` creation and disposal events dispatching for memory leak tracking as part of flutter/flutter#141198 ### Tests - Updates `decoration_test.dart` to test `BoxPainter` object creation and disposal events dispatching.
1 parent e5f62cc commit 8e94423

File tree

2 files changed

+4
-30
lines changed

2 files changed

+4
-30
lines changed

packages/flutter/lib/src/painting/decoration.dart

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,9 @@ 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].
200200
abstract class BoxPainter {
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-
}
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]);
213204

214205
/// Paints the [Decoration] for which this object was created on the
215206
/// given canvas using the given configuration.
@@ -252,9 +243,5 @@ abstract class BoxPainter {
252243
/// The [onChanged] callback will not be invoked after this method has been
253244
/// called.
254245
@mustCallSuper
255-
void dispose() {
256-
if (kFlutterMemoryAllocationsEnabled) {
257-
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
258-
}
259-
}
246+
void dispose() { }
260247
}

packages/flutter/test/painting/decoration_test.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import 'package:fake_async/fake_async.dart';
99
import 'package:flutter/foundation.dart';
1010
import 'package:flutter/painting.dart';
1111
import 'package:flutter_test/flutter_test.dart';
12-
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
1312

1413
import '../image_data.dart';
1514
import '../painting/mocks_for_image_cache.dart';
@@ -814,16 +813,4 @@ void main() {
814813

815814
info.dispose();
816815
}, skip: kIsWeb); // https://github.com/flutter/flutter/issues/87442
817-
818-
test('$BoxPainter dispatches memory events', () async {
819-
await expectLater(
820-
await memoryEvents(() => _BoxPainter().dispose(), _BoxPainter),
821-
areCreateAndDispose,
822-
);
823-
});
824-
}
825-
826-
class _BoxPainter extends BoxPainter {
827-
@override
828-
void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {}
829816
}

0 commit comments

Comments
 (0)