Unverified Commit f667376c authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

Rename MemoryAllocations to FlutterMemoryAllocations. (#140623)

Contributes to https://github.com/flutter/flutter/issues/140622
parent 59242b75
......@@ -300,10 +300,10 @@ class AnimationController extends Animation<double>
_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<double>
return true;
}());
if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this);
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
}
_ticker!.dispose();
_ticker = null;
......
......@@ -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;
......
......@@ -45,7 +45,7 @@ abstract class ObjectEvent{
/// The method enables code like:
/// ```dart
/// void myDartMethod(Map<Object, Map<String, Object>> event) {}
/// MemoryAllocations.instance
/// FlutterMemoryAllocations.instance
/// .addListener((ObjectEvent event) => myDartMethod(event.toMap()));
/// ```
Map<Object, Map<String, Object>> 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.
///
......
......@@ -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;
......
......@@ -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);
}
}
......
......@@ -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();
......
......@@ -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);
}
}
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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(() {
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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();
......
......@@ -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();
......
......@@ -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();
......
......@@ -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(() {
......
......@@ -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;
......
......@@ -34,7 +34,7 @@ class DisposableBuildContext<T extends State> {
// 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<T extends State> {
// 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;
}
......
......@@ -1006,7 +1006,7 @@ abstract class State<T extends StatefulWidget> 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<T extends StatefulWidget> 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;
......
......@@ -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) {
......
......@@ -145,7 +145,7 @@ abstract class Route<T> {
/// 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<T> {
_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();
......
......@@ -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) {
......
......@@ -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();
......
......@@ -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();
......
......@@ -26,7 +26,7 @@ class PrintOverrideTestBinding extends AutomatedTestWidgetsFlutterBinding {
}
void main() {
final MemoryAllocations ma = MemoryAllocations.instance;
final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance;
PrintOverrideTestBinding();
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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<ObjectCreated>());
expect(events.last, isA<ObjectDisposed>());
MemoryAllocations.instance.removeListener(listener);
FlutterMemoryAllocations.instance.removeListener(listener);
});
testWidgets('Route didAdd and dispose in same frame work', (WidgetTester tester) async {
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment