Skip to content

Commit

Permalink
Reverts "BoxPainter should dispatch creation and disposal events." (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
auto-submit[bot] authored Jan 15, 2024
1 parent e5f62cc commit 8e94423
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 30 deletions.
21 changes: 4 additions & 17 deletions packages/flutter/lib/src/painting/decoration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,9 @@ abstract class Decoration with Diagnosticable {
/// happens, the [onChanged] callback will be invoked. To stop this callback
/// from being called after the painter has been discarded, call [dispose].
abstract class BoxPainter {
/// Default abstract constructor for box painters.
BoxPainter([this.onChanged]) {
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/painting.dart',
className: '$BoxPainter',
object: this,
);
}
}
/// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const BoxPainter([this.onChanged]);

/// Paints the [Decoration] for which this object was created on the
/// given canvas using the given configuration.
Expand Down Expand Up @@ -252,9 +243,5 @@ abstract class BoxPainter {
/// The [onChanged] callback will not be invoked after this method has been
/// called.
@mustCallSuper
void dispose() {
if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
}
}
void dispose() { }
}
13 changes: 0 additions & 13 deletions packages/flutter/test/painting/decoration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:fake_async/fake_async.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';

import '../image_data.dart';
import '../painting/mocks_for_image_cache.dart';
Expand Down Expand Up @@ -814,16 +813,4 @@ void main() {

info.dispose();
}, skip: kIsWeb); // https://github.com/flutter/flutter/issues/87442

test('$BoxPainter dispatches memory events', () async {
await expectLater(
await memoryEvents(() => _BoxPainter().dispose(), _BoxPainter),
areCreateAndDispose,
);
});
}

class _BoxPainter extends BoxPainter {
@override
void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {}
}

0 comments on commit 8e94423

Please sign in to comment.