forked from firka/flutter
SnapshotPainter should dispatch creation and disposal events. (#138810)
This commit is contained in:
committed by
GitHub
parent
3c422dd750
commit
6c29986b28
@@ -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 @@ class _RenderSnapshotWidget extends RenderProxyBox {
|
||||
/// }
|
||||
/// ```
|
||||
/// {@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
|
||||
|
||||
@@ -326,6 +326,16 @@ void main() {
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user