File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed
Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -822,6 +822,16 @@ typedef LayoutCallback<T extends Constraints> = void Function(T constraints);
822822class _LocalSemanticsHandle implements SemanticsHandle {
823823 _LocalSemanticsHandle ._(PipelineOwner owner, this .listener)
824824 : _owner = owner {
825+ // TODO(polina-c): stop duplicating code across disposables
826+ // https://github.com/flutter/flutter/issues/137435
827+ if (kFlutterMemoryAllocationsEnabled) {
828+ MemoryAllocations .instance.dispatchObjectCreated (
829+ library: 'package:flutter/rendering.dart' ,
830+ className: '$_LocalSemanticsHandle ' ,
831+ object: this ,
832+ );
833+ }
834+
825835 if (listener != null ) {
826836 _owner.semanticsOwner! .addListener (listener! );
827837 }
@@ -834,6 +844,12 @@ class _LocalSemanticsHandle implements SemanticsHandle {
834844
835845 @override
836846 void dispose () {
847+ // TODO(polina-c): stop duplicating code across disposables
848+ // https://github.com/flutter/flutter/issues/137435
849+ if (kFlutterMemoryAllocationsEnabled) {
850+ MemoryAllocations .instance.dispatchObjectDisposed (object: this );
851+ }
852+
837853 if (listener != null ) {
838854 _owner.semanticsOwner! .removeListener (listener! );
839855 }
Original file line number Diff line number Diff line change @@ -191,7 +191,17 @@ mixin SemanticsBinding on BindingBase {
191191///
192192/// To obtain a [SemanticsHandle] , call [SemanticsBinding.ensureSemantics] .
193193class SemanticsHandle {
194- SemanticsHandle ._(this ._onDispose);
194+ SemanticsHandle ._(this ._onDispose) {
195+ // TODO(polina-c): stop duplicating code across disposables
196+ // https://github.com/flutter/flutter/issues/137435
197+ if (kFlutterMemoryAllocationsEnabled) {
198+ MemoryAllocations .instance.dispatchObjectCreated (
199+ library: 'package:flutter/semantics.dart' ,
200+ className: '$SemanticsHandle ' ,
201+ object: this ,
202+ );
203+ }
204+ }
195205
196206 final VoidCallback _onDispose;
197207
@@ -201,6 +211,12 @@ class SemanticsHandle {
201211 /// framework will stop generating semantics information.
202212 @mustCallSuper
203213 void dispose () {
214+ // TODO(polina-c): stop duplicating code across disposables
215+ // https://github.com/flutter/flutter/issues/137435
216+ if (kFlutterMemoryAllocationsEnabled) {
217+ MemoryAllocations .instance.dispatchObjectDisposed (object: this );
218+ }
219+
204220 _onDispose ();
205221 }
206222}
Original file line number Diff line number Diff line change @@ -82,4 +82,14 @@ void main() {
8282 expect (SemanticsBinding .instance.semanticsEnabled, isFalse);
8383 expect (tester.binding.pipelineOwner.semanticsOwner, isNull);
8484 }, semanticsEnabled: false );
85+
86+ test ('SemanticsHandle dispatches memory events' , () async {
87+ await expectLater (
88+ await memoryEvents (
89+ () => SemanticsBinding .instance.ensureSemantics ().dispose (),
90+ SemanticsHandle ,
91+ ),
92+ areCreateAndDispose,
93+ );
94+ });
8595}
You can’t perform that action at this time.
0 commit comments