diff --git a/packages/flutter/lib/src/animation/animation_controller.dart b/packages/flutter/lib/src/animation/animation_controller.dart index 6aa5b3d494..27919f2c1b 100644 --- a/packages/flutter/lib/src/animation/animation_controller.dart +++ b/packages/flutter/lib/src/animation/animation_controller.dart @@ -300,10 +300,10 @@ class AnimationController extends Animation _internalSetValue(value); } - /// Dispatches event of object creation to [MemoryAllocations.instance]. + /// Dispatches event of object creation to [FlutterMemoryAllocations.instance]. void _maybeDispatchObjectCreation() { if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: _flutterAnimationLibrary, className: '$AnimationController', object: this, @@ -833,7 +833,7 @@ class AnimationController extends Animation return true; }()); if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _ticker!.dispose(); _ticker = null; diff --git a/packages/flutter/lib/src/foundation/change_notifier.dart b/packages/flutter/lib/src/foundation/change_notifier.dart index 7bfc2fb294..27ef987ef7 100644 --- a/packages/flutter/lib/src/foundation/change_notifier.dart +++ b/packages/flutter/lib/src/foundation/change_notifier.dart @@ -148,7 +148,7 @@ mixin class ChangeNotifier implements Listenable { bool _debugDisposed = false; /// If true, the event [ObjectCreated] for this instance was dispatched to - /// [MemoryAllocations]. + /// [FlutterMemoryAllocations]. /// /// As [ChangedNotifier] is used as mixin, it does not have constructor, /// so we use [addListener] to dispatch the event. @@ -207,7 +207,7 @@ mixin class ChangeNotifier implements Listenable { @protected bool get hasListeners => _count > 0; - /// Dispatches event of the [object] creation to [MemoryAllocations.instance]. + /// Dispatches event of the [object] creation to [FlutterMemoryAllocations.instance]. /// /// If the event was already dispatched or [kFlutterMemoryAllocationsEnabled] /// is false, the method is noop. @@ -231,7 +231,7 @@ mixin class ChangeNotifier implements Listenable { // Tree shaker does not include this method and the class MemoryAllocations // if kFlutterMemoryAllocationsEnabled is false. if (kFlutterMemoryAllocationsEnabled && !object._creationDispatched) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: _flutterFoundationLibrary, className: '$ChangeNotifier', object: object, @@ -384,7 +384,7 @@ mixin class ChangeNotifier implements Listenable { return true; }()); if (kFlutterMemoryAllocationsEnabled && _creationDispatched) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _listeners = _emptyListeners; _count = 0; diff --git a/packages/flutter/lib/src/foundation/memory_allocations.dart b/packages/flutter/lib/src/foundation/memory_allocations.dart index 4b04e471a2..31307a7744 100644 --- a/packages/flutter/lib/src/foundation/memory_allocations.dart +++ b/packages/flutter/lib/src/foundation/memory_allocations.dart @@ -45,7 +45,7 @@ abstract class ObjectEvent{ /// The method enables code like: /// ```dart /// void myDartMethod(Map> event) {} - /// MemoryAllocations.instance + /// FlutterMemoryAllocations.instance /// .addListener((ObjectEvent event) => myDartMethod(event.toMap())); /// ``` Map> toMap(); @@ -97,13 +97,21 @@ class ObjectDisposed extends ObjectEvent { } } +/// An interface for listening to object lifecycle events. +@Deprecated( + 'Use `FlutterMemoryAllocations` instead. ' + 'The class `MemoryAllocations` will be introduced in a pure Dart library. ' + 'This feature was deprecated after v3.18.0-18.0.pre.' +) +typedef MemoryAllocations = FlutterMemoryAllocations; + /// An interface for listening to object lifecycle events. /// /// If [kFlutterMemoryAllocationsEnabled] is true, -/// [MemoryAllocations] listens to creation and disposal events +/// [FlutterMemoryAllocations] listens to creation and disposal events /// for disposable objects in Flutter Framework. -/// To dispatch events for other objects, invoke -/// [MemoryAllocations.dispatchObjectEvent]. +/// To dispatch other events objects, invoke +/// [FlutterMemoryAllocations.dispatchObjectEvent]. /// /// Use this class with condition `kFlutterMemoryAllocationsEnabled`, /// to make sure not to increase size of the application by the code @@ -111,13 +119,13 @@ class ObjectDisposed extends ObjectEvent { /// /// The class is optimized for massive event flow and small number of /// added or removed listeners. -class MemoryAllocations { - MemoryAllocations._(); +class FlutterMemoryAllocations { + FlutterMemoryAllocations._(); - /// The shared instance of [MemoryAllocations]. + /// The shared instance of [FlutterMemoryAllocations]. /// /// Only call this when [kFlutterMemoryAllocationsEnabled] is true. - static final MemoryAllocations instance = MemoryAllocations._(); + static final FlutterMemoryAllocations instance = FlutterMemoryAllocations._(); /// List of listeners. /// diff --git a/packages/flutter/lib/src/gestures/multidrag.dart b/packages/flutter/lib/src/gestures/multidrag.dart index 1bc7fbeb09..c58be81889 100644 --- a/packages/flutter/lib/src/gestures/multidrag.dart +++ b/packages/flutter/lib/src/gestures/multidrag.dart @@ -37,7 +37,7 @@ abstract class MultiDragPointerState { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/gestures.dart', className: '$MultiDragPointerState', object: this, @@ -191,7 +191,7 @@ abstract class MultiDragPointerState { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _arenaEntry?.resolve(GestureDisposition.rejected); _arenaEntry = null; diff --git a/packages/flutter/lib/src/gestures/recognizer.dart b/packages/flutter/lib/src/gestures/recognizer.dart index 4e271208a9..9a9ecb4b9a 100644 --- a/packages/flutter/lib/src/gestures/recognizer.dart +++ b/packages/flutter/lib/src/gestures/recognizer.dart @@ -108,7 +108,7 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/gestures.dart', className: '$GestureRecognizer', object: this, @@ -280,7 +280,7 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } } diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index ee230561c6..891c2625be 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -713,7 +713,7 @@ abstract class InkFeature { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/material.dart', className: '$InkFeature', object: this, @@ -747,7 +747,7 @@ abstract class InkFeature { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _controller._removeFeature(this); onRemoved?.call(); diff --git a/packages/flutter/lib/src/painting/image_stream.dart b/packages/flutter/lib/src/painting/image_stream.dart index 0d5dde6751..ffdcf45452 100644 --- a/packages/flutter/lib/src/painting/image_stream.dart +++ b/packages/flutter/lib/src/painting/image_stream.dart @@ -442,7 +442,7 @@ class ImageStreamCompleterHandle { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: _flutterWidgetsLibrary, className: '$ImageStreamCompleterHandle', object: this, @@ -467,7 +467,7 @@ class ImageStreamCompleterHandle { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } } } diff --git a/packages/flutter/lib/src/painting/text_painter.dart b/packages/flutter/lib/src/painting/text_painter.dart index c622d57d08..415db9a1b6 100644 --- a/packages/flutter/lib/src/painting/text_painter.dart +++ b/packages/flutter/lib/src/painting/text_painter.dart @@ -506,7 +506,7 @@ class TextPainter { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: _flutterPaintingLibrary, className: '$TextPainter', object: this, @@ -1632,7 +1632,7 @@ class TextPainter { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _layoutTemplate?.dispose(); _layoutTemplate = null; diff --git a/packages/flutter/lib/src/rendering/layer.dart b/packages/flutter/lib/src/rendering/layer.dart index 2a53cafb8b..a50db424a2 100644 --- a/packages/flutter/lib/src/rendering/layer.dart +++ b/packages/flutter/lib/src/rendering/layer.dart @@ -140,7 +140,7 @@ abstract class Layer with DiagnosticableTreeMixin { /// Creates an instance of Layer. Layer() { if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: _flutterRenderingLibrary, className: '$Layer', object: this, @@ -335,7 +335,7 @@ abstract class Layer with DiagnosticableTreeMixin { return true; }()); if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _engineLayer?.dispose(); _engineLayer = null; diff --git a/packages/flutter/lib/src/rendering/object.dart b/packages/flutter/lib/src/rendering/object.dart index 50ea05e645..4d01ad06f5 100644 --- a/packages/flutter/lib/src/rendering/object.dart +++ b/packages/flutter/lib/src/rendering/object.dart @@ -825,7 +825,7 @@ class _LocalSemanticsHandle implements SemanticsHandle { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/rendering.dart', className: '$_LocalSemanticsHandle', object: this, @@ -847,7 +847,7 @@ class _LocalSemanticsHandle implements SemanticsHandle { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } if (listener != null) { @@ -915,7 +915,7 @@ class PipelineOwner with DiagnosticableTreeMixin { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/rendering.dart', className: '$PipelineOwner', object: this, @@ -1460,7 +1460,7 @@ class PipelineOwner with DiagnosticableTreeMixin { assert(_manifold == null); assert(_debugParent == null); if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _semanticsOwner?.dispose(); _semanticsOwner = null; @@ -1656,7 +1656,7 @@ abstract class RenderObject with DiagnosticableTreeMixin implements HitTestTarge /// Initializes internal fields for subclasses. RenderObject() { if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: _flutterRenderingLibrary, className: '$RenderObject', object: this, @@ -1723,7 +1723,7 @@ abstract class RenderObject with DiagnosticableTreeMixin implements HitTestTarge void dispose() { assert(!_debugDisposed); if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _layerHandle.layer = null; assert(() { diff --git a/packages/flutter/lib/src/scheduler/binding.dart b/packages/flutter/lib/src/scheduler/binding.dart index 2fa31174af..6bad5b1c6f 100644 --- a/packages/flutter/lib/src/scheduler/binding.dart +++ b/packages/flutter/lib/src/scheduler/binding.dart @@ -200,7 +200,7 @@ class PerformanceModeRequestHandle { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/scheduler.dart', className: '$PerformanceModeRequestHandle', object: this, @@ -219,7 +219,7 @@ class PerformanceModeRequestHandle { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _cleanup!(); _cleanup = null; diff --git a/packages/flutter/lib/src/scheduler/ticker.dart b/packages/flutter/lib/src/scheduler/ticker.dart index ce6cee8641..c08122911b 100644 --- a/packages/flutter/lib/src/scheduler/ticker.dart +++ b/packages/flutter/lib/src/scheduler/ticker.dart @@ -74,7 +74,7 @@ class Ticker { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/scheduler.dart', className: '$Ticker', object: this, @@ -331,7 +331,7 @@ class Ticker { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } if (_future != null) { diff --git a/packages/flutter/lib/src/semantics/binding.dart b/packages/flutter/lib/src/semantics/binding.dart index 9f1353900b..c12ec7b035 100644 --- a/packages/flutter/lib/src/semantics/binding.dart +++ b/packages/flutter/lib/src/semantics/binding.dart @@ -195,7 +195,7 @@ class SemanticsHandle { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/semantics.dart', className: '$SemanticsHandle', object: this, @@ -214,7 +214,7 @@ class SemanticsHandle { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _onDispose(); diff --git a/packages/flutter/lib/src/semantics/semantics.dart b/packages/flutter/lib/src/semantics/semantics.dart index f30051691b..b7aab9c21a 100644 --- a/packages/flutter/lib/src/semantics/semantics.dart +++ b/packages/flutter/lib/src/semantics/semantics.dart @@ -3321,7 +3321,7 @@ class SemanticsOwner extends ChangeNotifier { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/semantics.dart', className: '$SemanticsOwner', object: this, @@ -3349,7 +3349,7 @@ class SemanticsOwner extends ChangeNotifier { @override void dispose() { if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _dirtyNodes.clear(); _nodes.clear(); diff --git a/packages/flutter/lib/src/services/restoration.dart b/packages/flutter/lib/src/services/restoration.dart index a5c37c58ef..d49af9183d 100644 --- a/packages/flutter/lib/src/services/restoration.dart +++ b/packages/flutter/lib/src/services/restoration.dart @@ -951,10 +951,10 @@ class RestorationBucket { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 - /// Dispatches event of object creation to [MemoryAllocations.instance]. + /// Dispatches event of object creation to [FlutterMemoryAllocations.instance]. void _maybeDispatchObjectCreation() { if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/services.dart', className: '$RestorationBucket', object: this, @@ -979,7 +979,7 @@ class RestorationBucket { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _visitChildren(_dropChild, concurrentModification: true); _claimedChildren.clear(); diff --git a/packages/flutter/lib/src/widgets/app_lifecycle_listener.dart b/packages/flutter/lib/src/widgets/app_lifecycle_listener.dart index 3ed897d6b7..8074389405 100644 --- a/packages/flutter/lib/src/widgets/app_lifecycle_listener.dart +++ b/packages/flutter/lib/src/widgets/app_lifecycle_listener.dart @@ -76,7 +76,7 @@ class AppLifecycleListener with WidgetsBindingObserver, Diagnosticable { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/widgets.dart', className: '$AppLifecycleListener', object: this, @@ -186,7 +186,7 @@ class AppLifecycleListener with WidgetsBindingObserver, Diagnosticable { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } binding.removeObserver(this); assert(() { diff --git a/packages/flutter/lib/src/widgets/banner.dart b/packages/flutter/lib/src/widgets/banner.dart index 00dc6c537f..08846c2bef 100644 --- a/packages/flutter/lib/src/widgets/banner.dart +++ b/packages/flutter/lib/src/widgets/banner.dart @@ -67,7 +67,7 @@ class BannerPainter extends CustomPainter { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: _flutterWidgetsLibrary, className: '$BannerPainter', object: this, @@ -132,7 +132,7 @@ class BannerPainter extends CustomPainter { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _textPainter?.dispose(); _textPainter = null; diff --git a/packages/flutter/lib/src/widgets/disposable_build_context.dart b/packages/flutter/lib/src/widgets/disposable_build_context.dart index bc9d869fec..64ff92dc98 100644 --- a/packages/flutter/lib/src/widgets/disposable_build_context.dart +++ b/packages/flutter/lib/src/widgets/disposable_build_context.dart @@ -34,7 +34,7 @@ class DisposableBuildContext { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/widgets.dart', className: '$DisposableBuildContext', object: this, @@ -81,7 +81,7 @@ class DisposableBuildContext { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _state = null; } diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index a877c2d950..2e2c711310 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -1006,7 +1006,7 @@ abstract class State with Diagnosticable { void initState() { assert(_debugLifecycleState == _StateLifecycle.created); if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: _flutterWidgetsLibrary, className: '$State', object: this, @@ -1341,7 +1341,7 @@ abstract class State with Diagnosticable { return true; }()); if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } } @@ -3387,7 +3387,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { Element(Widget widget) : _widget = widget { if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: _flutterWidgetsLibrary, className: '$Element', object: this, @@ -4542,7 +4542,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { assert(_widget != null); // Use the private property to avoid a CastError during hot reload. assert(owner != null); if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } // Use the private property to avoid a CastError during hot reload. final Key? key = _widget?.key; diff --git a/packages/flutter/lib/src/widgets/heroes.dart b/packages/flutter/lib/src/widgets/heroes.dart index 2a8d3abe6f..aca86e3dfd 100644 --- a/packages/flutter/lib/src/widgets/heroes.dart +++ b/packages/flutter/lib/src/widgets/heroes.dart @@ -788,7 +788,7 @@ class HeroController extends NavigatorObserver { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/widgets.dart', className: '$HeroController', object: this, @@ -1056,7 +1056,7 @@ class HeroController extends NavigatorObserver { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } for (final _HeroFlight flight in _flights.values) { diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index 26e4a83032..a781e6e3f5 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -145,7 +145,7 @@ abstract class Route { /// used instead. Route({ RouteSettings? settings }) : _settings = settings ?? const RouteSettings() { if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/widgets.dart', className: '$Route<$T>', object: this, @@ -518,7 +518,7 @@ abstract class Route { _restorationScopeId.dispose(); _disposeCompleter.complete(); if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } } @@ -2923,7 +2923,7 @@ class _RouteEntry extends RouteTransitionRecord { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/widgets.dart', className: '$_RouteEntry', object: this, @@ -3163,7 +3163,7 @@ class _RouteEntry extends RouteTransitionRecord { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } currentState = _RouteLifecycle.disposed; route.dispose(); diff --git a/packages/flutter/lib/src/widgets/overlay.dart b/packages/flutter/lib/src/widgets/overlay.dart index 9da0647547..1f178f4484 100644 --- a/packages/flutter/lib/src/widgets/overlay.dart +++ b/packages/flutter/lib/src/widgets/overlay.dart @@ -168,10 +168,10 @@ class OverlayEntry implements Listenable { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 - /// Dispatches event of object creation to [MemoryAllocations.instance]. + /// Dispatches event of object creation to [FlutterMemoryAllocations.instance]. void _maybeDispatchObjectCreation() { if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: _flutterWidgetsLibrary, className: '$OverlayEntry', object: this, @@ -256,7 +256,7 @@ class OverlayEntry implements Listenable { assert(!_disposedByOwner); assert(_overlay == null, 'An OverlayEntry must first be removed from the Overlay before dispose is called.'); if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _disposedByOwner = true; if (!mounted) { diff --git a/packages/flutter/lib/src/widgets/scroll_activity.dart b/packages/flutter/lib/src/widgets/scroll_activity.dart index d1155727a7..aa0f92958e 100644 --- a/packages/flutter/lib/src/widgets/scroll_activity.dart +++ b/packages/flutter/lib/src/widgets/scroll_activity.dart @@ -61,7 +61,7 @@ abstract class ScrollActivity { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/widgets.dart', className: '$ScrollActivity', object: this, @@ -150,7 +150,7 @@ abstract class ScrollActivity { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _isDisposed = true; @@ -265,7 +265,7 @@ class ScrollDragController implements Drag { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/widgets.dart', className: '$ScrollDragController', object: this, @@ -450,7 +450,7 @@ class ScrollDragController implements Drag { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _lastDetails = null; onDragCanceled?.call(); diff --git a/packages/flutter/lib/src/widgets/text_selection.dart b/packages/flutter/lib/src/widgets/text_selection.dart index 83b3d97337..a8c47cd61c 100644 --- a/packages/flutter/lib/src/widgets/text_selection.dart +++ b/packages/flutter/lib/src/widgets/text_selection.dart @@ -335,7 +335,7 @@ class TextSelectionOverlay { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/widgets.dart', className: '$TextSelectionOverlay', object: this, @@ -597,7 +597,7 @@ class TextSelectionOverlay { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } _selectionOverlay.dispose(); renderObject.selectionStartInViewport.removeListener(_updateTextSelectionOverlayVisibilities); @@ -974,7 +974,7 @@ class SelectionOverlay { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectCreated( + FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/widgets.dart', className: '$SelectionOverlay', object: this, @@ -1533,7 +1533,7 @@ class SelectionOverlay { // TODO(polina-c): stop duplicating code across disposables // https://github.com/flutter/flutter/issues/137435 if (kFlutterMemoryAllocationsEnabled) { - MemoryAllocations.instance.dispatchObjectDisposed(object: this); + FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); } hide(); _magnifierInfo.dispose(); diff --git a/packages/flutter/test/foundation/memory_allocations_test.dart b/packages/flutter/test/foundation/memory_allocations_test.dart index 537061ad72..f6721e9bfd 100644 --- a/packages/flutter/test/foundation/memory_allocations_test.dart +++ b/packages/flutter/test/foundation/memory_allocations_test.dart @@ -26,7 +26,7 @@ class PrintOverrideTestBinding extends AutomatedTestWidgetsFlutterBinding { } void main() { - final MemoryAllocations ma = MemoryAllocations.instance; + final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance; PrintOverrideTestBinding(); diff --git a/packages/flutter/test/rendering/memory_allocations_test.dart b/packages/flutter/test/rendering/memory_allocations_test.dart index bb93f99851..8405d02ea0 100644 --- a/packages/flutter/test/rendering/memory_allocations_test.dart +++ b/packages/flutter/test/rendering/memory_allocations_test.dart @@ -9,7 +9,7 @@ import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - final MemoryAllocations ma = MemoryAllocations.instance; + final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance; setUp(() { assert(!ma.hasListeners); diff --git a/packages/flutter/test/widgets/memory_allocations_test.dart b/packages/flutter/test/widgets/memory_allocations_test.dart index aff4d51900..a6c45cc457 100644 --- a/packages/flutter/test/widgets/memory_allocations_test.dart +++ b/packages/flutter/test/widgets/memory_allocations_test.dart @@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; int _disposals = 0; void main() { - final MemoryAllocations ma = MemoryAllocations.instance; + final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance; test('Publishers dispatch events in debug mode', () async { void listener(ObjectEvent event) { diff --git a/packages/flutter/test/widgets/navigator_test.dart b/packages/flutter/test/widgets/navigator_test.dart index 23c04080f9..15aa75341d 100644 --- a/packages/flutter/test/widgets/navigator_test.dart +++ b/packages/flutter/test/widgets/navigator_test.dart @@ -652,14 +652,14 @@ void main() { events.add(event); } } - MemoryAllocations.instance.addListener(listener); + FlutterMemoryAllocations.instance.addListener(listener); await createAndDisposeRoute(); expect(events, hasLength(2)); expect(events.first, isA()); expect(events.last, isA()); - MemoryAllocations.instance.removeListener(listener); + FlutterMemoryAllocations.instance.removeListener(listener); }); testWidgets('Route didAdd and dispose in same frame work', (WidgetTester tester) async { diff --git a/packages/flutter/test_release/foundation/memory_allocations_test.dart b/packages/flutter/test_release/foundation/memory_allocations_test.dart index 21886e3881..3102f25a59 100644 --- a/packages/flutter/test_release/foundation/memory_allocations_test.dart +++ b/packages/flutter/test_release/foundation/memory_allocations_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - final MemoryAllocations ma = MemoryAllocations.instance; + final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance; setUp(() { assert(!ma.hasListeners); @@ -20,7 +20,7 @@ void main() { }); testWidgets( - '$MemoryAllocations is noop when kFlutterMemoryAllocationsEnabled is false.', + '$FlutterMemoryAllocations is noop when kFlutterMemoryAllocationsEnabled is false.', (WidgetTester tester) async { ObjectEvent? receivedEvent; ObjectEvent listener(ObjectEvent event) => receivedEvent = event; diff --git a/packages/flutter/test_release/rendering/memory_allocations_test.dart b/packages/flutter/test_release/rendering/memory_allocations_test.dart index f82b2f6786..cfaf4ed5c7 100644 --- a/packages/flutter/test_release/rendering/memory_allocations_test.dart +++ b/packages/flutter/test_release/rendering/memory_allocations_test.dart @@ -9,14 +9,14 @@ import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - final MemoryAllocations ma = MemoryAllocations.instance; + final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance; setUp(() { assert(!ma.hasListeners); }); testWidgets( - '$MemoryAllocations is noop when kFlutterMemoryAllocationsEnabled is false.', + '$FlutterMemoryAllocations is noop when kFlutterMemoryAllocationsEnabled is false.', (WidgetTester tester) async { ObjectEvent? receivedEvent; ObjectEvent listener(ObjectEvent event) => receivedEvent = event; diff --git a/packages/flutter/test_release/widgets/memory_allocations_test.dart b/packages/flutter/test_release/widgets/memory_allocations_test.dart index 4057379308..2179b6948e 100644 --- a/packages/flutter/test_release/widgets/memory_allocations_test.dart +++ b/packages/flutter/test_release/widgets/memory_allocations_test.dart @@ -7,14 +7,14 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - final MemoryAllocations ma = MemoryAllocations.instance; + final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance; setUp(() { assert(!ma.hasListeners); }); testWidgets( - '$MemoryAllocations is noop when kFlutterMemoryAllocationsEnabled is false.', + '$FlutterMemoryAllocations is noop when kFlutterMemoryAllocationsEnabled is false.', (WidgetTester tester) async { ObjectEvent? receivedEvent; ObjectEvent listener(ObjectEvent event) => receivedEvent = event;