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> ...@@ -300,10 +300,10 @@ class AnimationController extends Animation<double>
_internalSetValue(value); _internalSetValue(value);
} }
/// Dispatches event of object creation to [MemoryAllocations.instance]. /// Dispatches event of object creation to [FlutterMemoryAllocations.instance].
void _maybeDispatchObjectCreation() { void _maybeDispatchObjectCreation() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: _flutterAnimationLibrary, library: _flutterAnimationLibrary,
className: '$AnimationController', className: '$AnimationController',
object: this, object: this,
...@@ -833,7 +833,7 @@ class AnimationController extends Animation<double> ...@@ -833,7 +833,7 @@ class AnimationController extends Animation<double>
return true; return true;
}()); }());
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_ticker!.dispose(); _ticker!.dispose();
_ticker = null; _ticker = null;
......
...@@ -148,7 +148,7 @@ mixin class ChangeNotifier implements Listenable { ...@@ -148,7 +148,7 @@ mixin class ChangeNotifier implements Listenable {
bool _debugDisposed = false; bool _debugDisposed = false;
/// If true, the event [ObjectCreated] for this instance was dispatched to /// If true, the event [ObjectCreated] for this instance was dispatched to
/// [MemoryAllocations]. /// [FlutterMemoryAllocations].
/// ///
/// As [ChangedNotifier] is used as mixin, it does not have constructor, /// As [ChangedNotifier] is used as mixin, it does not have constructor,
/// so we use [addListener] to dispatch the event. /// so we use [addListener] to dispatch the event.
...@@ -207,7 +207,7 @@ mixin class ChangeNotifier implements Listenable { ...@@ -207,7 +207,7 @@ mixin class ChangeNotifier implements Listenable {
@protected @protected
bool get hasListeners => _count > 0; 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] /// If the event was already dispatched or [kFlutterMemoryAllocationsEnabled]
/// is false, the method is noop. /// is false, the method is noop.
...@@ -231,7 +231,7 @@ mixin class ChangeNotifier implements Listenable { ...@@ -231,7 +231,7 @@ mixin class ChangeNotifier implements Listenable {
// Tree shaker does not include this method and the class MemoryAllocations // Tree shaker does not include this method and the class MemoryAllocations
// if kFlutterMemoryAllocationsEnabled is false. // if kFlutterMemoryAllocationsEnabled is false.
if (kFlutterMemoryAllocationsEnabled && !object._creationDispatched) { if (kFlutterMemoryAllocationsEnabled && !object._creationDispatched) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: _flutterFoundationLibrary, library: _flutterFoundationLibrary,
className: '$ChangeNotifier', className: '$ChangeNotifier',
object: object, object: object,
...@@ -384,7 +384,7 @@ mixin class ChangeNotifier implements Listenable { ...@@ -384,7 +384,7 @@ mixin class ChangeNotifier implements Listenable {
return true; return true;
}()); }());
if (kFlutterMemoryAllocationsEnabled && _creationDispatched) { if (kFlutterMemoryAllocationsEnabled && _creationDispatched) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_listeners = _emptyListeners; _listeners = _emptyListeners;
_count = 0; _count = 0;
......
...@@ -45,7 +45,7 @@ abstract class ObjectEvent{ ...@@ -45,7 +45,7 @@ abstract class ObjectEvent{
/// The method enables code like: /// The method enables code like:
/// ```dart /// ```dart
/// void myDartMethod(Map<Object, Map<String, Object>> event) {} /// void myDartMethod(Map<Object, Map<String, Object>> event) {}
/// MemoryAllocations.instance /// FlutterMemoryAllocations.instance
/// .addListener((ObjectEvent event) => myDartMethod(event.toMap())); /// .addListener((ObjectEvent event) => myDartMethod(event.toMap()));
/// ``` /// ```
Map<Object, Map<String, Object>> toMap(); Map<Object, Map<String, Object>> toMap();
...@@ -97,13 +97,21 @@ class ObjectDisposed extends ObjectEvent { ...@@ -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. /// An interface for listening to object lifecycle events.
/// ///
/// If [kFlutterMemoryAllocationsEnabled] is true, /// If [kFlutterMemoryAllocationsEnabled] is true,
/// [MemoryAllocations] listens to creation and disposal events /// [FlutterMemoryAllocations] listens to creation and disposal events
/// for disposable objects in Flutter Framework. /// for disposable objects in Flutter Framework.
/// To dispatch events for other objects, invoke /// To dispatch other events objects, invoke
/// [MemoryAllocations.dispatchObjectEvent]. /// [FlutterMemoryAllocations.dispatchObjectEvent].
/// ///
/// Use this class with condition `kFlutterMemoryAllocationsEnabled`, /// Use this class with condition `kFlutterMemoryAllocationsEnabled`,
/// to make sure not to increase size of the application by the code /// to make sure not to increase size of the application by the code
...@@ -111,13 +119,13 @@ class ObjectDisposed extends ObjectEvent { ...@@ -111,13 +119,13 @@ class ObjectDisposed extends ObjectEvent {
/// ///
/// The class is optimized for massive event flow and small number of /// The class is optimized for massive event flow and small number of
/// added or removed listeners. /// added or removed listeners.
class MemoryAllocations { class FlutterMemoryAllocations {
MemoryAllocations._(); FlutterMemoryAllocations._();
/// The shared instance of [MemoryAllocations]. /// The shared instance of [FlutterMemoryAllocations].
/// ///
/// Only call this when [kFlutterMemoryAllocationsEnabled] is true. /// Only call this when [kFlutterMemoryAllocationsEnabled] is true.
static final MemoryAllocations instance = MemoryAllocations._(); static final FlutterMemoryAllocations instance = FlutterMemoryAllocations._();
/// List of listeners. /// List of listeners.
/// ///
......
...@@ -37,7 +37,7 @@ abstract class MultiDragPointerState { ...@@ -37,7 +37,7 @@ abstract class MultiDragPointerState {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/gestures.dart', library: 'package:flutter/gestures.dart',
className: '$MultiDragPointerState', className: '$MultiDragPointerState',
object: this, object: this,
...@@ -191,7 +191,7 @@ abstract class MultiDragPointerState { ...@@ -191,7 +191,7 @@ abstract class MultiDragPointerState {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_arenaEntry?.resolve(GestureDisposition.rejected); _arenaEntry?.resolve(GestureDisposition.rejected);
_arenaEntry = null; _arenaEntry = null;
......
...@@ -108,7 +108,7 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT ...@@ -108,7 +108,7 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/gestures.dart', library: 'package:flutter/gestures.dart',
className: '$GestureRecognizer', className: '$GestureRecognizer',
object: this, object: this,
...@@ -280,7 +280,7 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT ...@@ -280,7 +280,7 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
} }
......
...@@ -713,7 +713,7 @@ abstract class InkFeature { ...@@ -713,7 +713,7 @@ abstract class InkFeature {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/material.dart', library: 'package:flutter/material.dart',
className: '$InkFeature', className: '$InkFeature',
object: this, object: this,
...@@ -747,7 +747,7 @@ abstract class InkFeature { ...@@ -747,7 +747,7 @@ abstract class InkFeature {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_controller._removeFeature(this); _controller._removeFeature(this);
onRemoved?.call(); onRemoved?.call();
......
...@@ -442,7 +442,7 @@ class ImageStreamCompleterHandle { ...@@ -442,7 +442,7 @@ class ImageStreamCompleterHandle {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: _flutterWidgetsLibrary, library: _flutterWidgetsLibrary,
className: '$ImageStreamCompleterHandle', className: '$ImageStreamCompleterHandle',
object: this, object: this,
...@@ -467,7 +467,7 @@ class ImageStreamCompleterHandle { ...@@ -467,7 +467,7 @@ class ImageStreamCompleterHandle {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
} }
} }
......
...@@ -506,7 +506,7 @@ class TextPainter { ...@@ -506,7 +506,7 @@ class TextPainter {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: _flutterPaintingLibrary, library: _flutterPaintingLibrary,
className: '$TextPainter', className: '$TextPainter',
object: this, object: this,
...@@ -1632,7 +1632,7 @@ class TextPainter { ...@@ -1632,7 +1632,7 @@ class TextPainter {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_layoutTemplate?.dispose(); _layoutTemplate?.dispose();
_layoutTemplate = null; _layoutTemplate = null;
......
...@@ -140,7 +140,7 @@ abstract class Layer with DiagnosticableTreeMixin { ...@@ -140,7 +140,7 @@ abstract class Layer with DiagnosticableTreeMixin {
/// Creates an instance of Layer. /// Creates an instance of Layer.
Layer() { Layer() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: _flutterRenderingLibrary, library: _flutterRenderingLibrary,
className: '$Layer', className: '$Layer',
object: this, object: this,
...@@ -335,7 +335,7 @@ abstract class Layer with DiagnosticableTreeMixin { ...@@ -335,7 +335,7 @@ abstract class Layer with DiagnosticableTreeMixin {
return true; return true;
}()); }());
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_engineLayer?.dispose(); _engineLayer?.dispose();
_engineLayer = null; _engineLayer = null;
......
...@@ -825,7 +825,7 @@ class _LocalSemanticsHandle implements SemanticsHandle { ...@@ -825,7 +825,7 @@ class _LocalSemanticsHandle implements SemanticsHandle {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/rendering.dart', library: 'package:flutter/rendering.dart',
className: '$_LocalSemanticsHandle', className: '$_LocalSemanticsHandle',
object: this, object: this,
...@@ -847,7 +847,7 @@ class _LocalSemanticsHandle implements SemanticsHandle { ...@@ -847,7 +847,7 @@ class _LocalSemanticsHandle implements SemanticsHandle {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
if (listener != null) { if (listener != null) {
...@@ -915,7 +915,7 @@ class PipelineOwner with DiagnosticableTreeMixin { ...@@ -915,7 +915,7 @@ class PipelineOwner with DiagnosticableTreeMixin {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/rendering.dart', library: 'package:flutter/rendering.dart',
className: '$PipelineOwner', className: '$PipelineOwner',
object: this, object: this,
...@@ -1460,7 +1460,7 @@ class PipelineOwner with DiagnosticableTreeMixin { ...@@ -1460,7 +1460,7 @@ class PipelineOwner with DiagnosticableTreeMixin {
assert(_manifold == null); assert(_manifold == null);
assert(_debugParent == null); assert(_debugParent == null);
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_semanticsOwner?.dispose(); _semanticsOwner?.dispose();
_semanticsOwner = null; _semanticsOwner = null;
...@@ -1656,7 +1656,7 @@ abstract class RenderObject with DiagnosticableTreeMixin implements HitTestTarge ...@@ -1656,7 +1656,7 @@ abstract class RenderObject with DiagnosticableTreeMixin implements HitTestTarge
/// Initializes internal fields for subclasses. /// Initializes internal fields for subclasses.
RenderObject() { RenderObject() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: _flutterRenderingLibrary, library: _flutterRenderingLibrary,
className: '$RenderObject', className: '$RenderObject',
object: this, object: this,
...@@ -1723,7 +1723,7 @@ abstract class RenderObject with DiagnosticableTreeMixin implements HitTestTarge ...@@ -1723,7 +1723,7 @@ abstract class RenderObject with DiagnosticableTreeMixin implements HitTestTarge
void dispose() { void dispose() {
assert(!_debugDisposed); assert(!_debugDisposed);
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_layerHandle.layer = null; _layerHandle.layer = null;
assert(() { assert(() {
......
...@@ -200,7 +200,7 @@ class PerformanceModeRequestHandle { ...@@ -200,7 +200,7 @@ class PerformanceModeRequestHandle {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/scheduler.dart', library: 'package:flutter/scheduler.dart',
className: '$PerformanceModeRequestHandle', className: '$PerformanceModeRequestHandle',
object: this, object: this,
...@@ -219,7 +219,7 @@ class PerformanceModeRequestHandle { ...@@ -219,7 +219,7 @@ class PerformanceModeRequestHandle {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_cleanup!(); _cleanup!();
_cleanup = null; _cleanup = null;
......
...@@ -74,7 +74,7 @@ class Ticker { ...@@ -74,7 +74,7 @@ class Ticker {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/scheduler.dart', library: 'package:flutter/scheduler.dart',
className: '$Ticker', className: '$Ticker',
object: this, object: this,
...@@ -331,7 +331,7 @@ class Ticker { ...@@ -331,7 +331,7 @@ class Ticker {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
if (_future != null) { if (_future != null) {
......
...@@ -195,7 +195,7 @@ class SemanticsHandle { ...@@ -195,7 +195,7 @@ class SemanticsHandle {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/semantics.dart', library: 'package:flutter/semantics.dart',
className: '$SemanticsHandle', className: '$SemanticsHandle',
object: this, object: this,
...@@ -214,7 +214,7 @@ class SemanticsHandle { ...@@ -214,7 +214,7 @@ class SemanticsHandle {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_onDispose(); _onDispose();
......
...@@ -3321,7 +3321,7 @@ class SemanticsOwner extends ChangeNotifier { ...@@ -3321,7 +3321,7 @@ class SemanticsOwner extends ChangeNotifier {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/semantics.dart', library: 'package:flutter/semantics.dart',
className: '$SemanticsOwner', className: '$SemanticsOwner',
object: this, object: this,
...@@ -3349,7 +3349,7 @@ class SemanticsOwner extends ChangeNotifier { ...@@ -3349,7 +3349,7 @@ class SemanticsOwner extends ChangeNotifier {
@override @override
void dispose() { void dispose() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_dirtyNodes.clear(); _dirtyNodes.clear();
_nodes.clear(); _nodes.clear();
......
...@@ -951,10 +951,10 @@ class RestorationBucket { ...@@ -951,10 +951,10 @@ class RestorationBucket {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // 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() { void _maybeDispatchObjectCreation() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/services.dart', library: 'package:flutter/services.dart',
className: '$RestorationBucket', className: '$RestorationBucket',
object: this, object: this,
...@@ -979,7 +979,7 @@ class RestorationBucket { ...@@ -979,7 +979,7 @@ class RestorationBucket {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_visitChildren(_dropChild, concurrentModification: true); _visitChildren(_dropChild, concurrentModification: true);
_claimedChildren.clear(); _claimedChildren.clear();
......
...@@ -76,7 +76,7 @@ class AppLifecycleListener with WidgetsBindingObserver, Diagnosticable { ...@@ -76,7 +76,7 @@ class AppLifecycleListener with WidgetsBindingObserver, Diagnosticable {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/widgets.dart', library: 'package:flutter/widgets.dart',
className: '$AppLifecycleListener', className: '$AppLifecycleListener',
object: this, object: this,
...@@ -186,7 +186,7 @@ class AppLifecycleListener with WidgetsBindingObserver, Diagnosticable { ...@@ -186,7 +186,7 @@ class AppLifecycleListener with WidgetsBindingObserver, Diagnosticable {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
binding.removeObserver(this); binding.removeObserver(this);
assert(() { assert(() {
......
...@@ -67,7 +67,7 @@ class BannerPainter extends CustomPainter { ...@@ -67,7 +67,7 @@ class BannerPainter extends CustomPainter {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: _flutterWidgetsLibrary, library: _flutterWidgetsLibrary,
className: '$BannerPainter', className: '$BannerPainter',
object: this, object: this,
...@@ -132,7 +132,7 @@ class BannerPainter extends CustomPainter { ...@@ -132,7 +132,7 @@ class BannerPainter extends CustomPainter {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_textPainter?.dispose(); _textPainter?.dispose();
_textPainter = null; _textPainter = null;
......
...@@ -34,7 +34,7 @@ class DisposableBuildContext<T extends State> { ...@@ -34,7 +34,7 @@ class DisposableBuildContext<T extends State> {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/widgets.dart', library: 'package:flutter/widgets.dart',
className: '$DisposableBuildContext', className: '$DisposableBuildContext',
object: this, object: this,
...@@ -81,7 +81,7 @@ class DisposableBuildContext<T extends State> { ...@@ -81,7 +81,7 @@ class DisposableBuildContext<T extends State> {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_state = null; _state = null;
} }
......
...@@ -1006,7 +1006,7 @@ abstract class State<T extends StatefulWidget> with Diagnosticable { ...@@ -1006,7 +1006,7 @@ abstract class State<T extends StatefulWidget> with Diagnosticable {
void initState() { void initState() {
assert(_debugLifecycleState == _StateLifecycle.created); assert(_debugLifecycleState == _StateLifecycle.created);
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: _flutterWidgetsLibrary, library: _flutterWidgetsLibrary,
className: '$State', className: '$State',
object: this, object: this,
...@@ -1341,7 +1341,7 @@ abstract class State<T extends StatefulWidget> with Diagnosticable { ...@@ -1341,7 +1341,7 @@ abstract class State<T extends StatefulWidget> with Diagnosticable {
return true; return true;
}()); }());
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
} }
...@@ -3387,7 +3387,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { ...@@ -3387,7 +3387,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
Element(Widget widget) Element(Widget widget)
: _widget = widget { : _widget = widget {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: _flutterWidgetsLibrary, library: _flutterWidgetsLibrary,
className: '$Element', className: '$Element',
object: this, object: this,
...@@ -4542,7 +4542,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { ...@@ -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(_widget != null); // Use the private property to avoid a CastError during hot reload.
assert(owner != null); assert(owner != null);
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
// Use the private property to avoid a CastError during hot reload. // Use the private property to avoid a CastError during hot reload.
final Key? key = _widget?.key; final Key? key = _widget?.key;
......
...@@ -788,7 +788,7 @@ class HeroController extends NavigatorObserver { ...@@ -788,7 +788,7 @@ class HeroController extends NavigatorObserver {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/widgets.dart', library: 'package:flutter/widgets.dart',
className: '$HeroController', className: '$HeroController',
object: this, object: this,
...@@ -1056,7 +1056,7 @@ class HeroController extends NavigatorObserver { ...@@ -1056,7 +1056,7 @@ class HeroController extends NavigatorObserver {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
for (final _HeroFlight flight in _flights.values) { for (final _HeroFlight flight in _flights.values) {
......
...@@ -145,7 +145,7 @@ abstract class Route<T> { ...@@ -145,7 +145,7 @@ abstract class Route<T> {
/// used instead. /// used instead.
Route({ RouteSettings? settings }) : _settings = settings ?? const RouteSettings() { Route({ RouteSettings? settings }) : _settings = settings ?? const RouteSettings() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/widgets.dart', library: 'package:flutter/widgets.dart',
className: '$Route<$T>', className: '$Route<$T>',
object: this, object: this,
...@@ -518,7 +518,7 @@ abstract class Route<T> { ...@@ -518,7 +518,7 @@ abstract class Route<T> {
_restorationScopeId.dispose(); _restorationScopeId.dispose();
_disposeCompleter.complete(); _disposeCompleter.complete();
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
} }
...@@ -2923,7 +2923,7 @@ class _RouteEntry extends RouteTransitionRecord { ...@@ -2923,7 +2923,7 @@ class _RouteEntry extends RouteTransitionRecord {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/widgets.dart', library: 'package:flutter/widgets.dart',
className: '$_RouteEntry', className: '$_RouteEntry',
object: this, object: this,
...@@ -3163,7 +3163,7 @@ class _RouteEntry extends RouteTransitionRecord { ...@@ -3163,7 +3163,7 @@ class _RouteEntry extends RouteTransitionRecord {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
currentState = _RouteLifecycle.disposed; currentState = _RouteLifecycle.disposed;
route.dispose(); route.dispose();
......
...@@ -168,10 +168,10 @@ class OverlayEntry implements Listenable { ...@@ -168,10 +168,10 @@ class OverlayEntry implements Listenable {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // 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() { void _maybeDispatchObjectCreation() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: _flutterWidgetsLibrary, library: _flutterWidgetsLibrary,
className: '$OverlayEntry', className: '$OverlayEntry',
object: this, object: this,
...@@ -256,7 +256,7 @@ class OverlayEntry implements Listenable { ...@@ -256,7 +256,7 @@ class OverlayEntry implements Listenable {
assert(!_disposedByOwner); assert(!_disposedByOwner);
assert(_overlay == null, 'An OverlayEntry must first be removed from the Overlay before dispose is called.'); assert(_overlay == null, 'An OverlayEntry must first be removed from the Overlay before dispose is called.');
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_disposedByOwner = true; _disposedByOwner = true;
if (!mounted) { if (!mounted) {
......
...@@ -61,7 +61,7 @@ abstract class ScrollActivity { ...@@ -61,7 +61,7 @@ abstract class ScrollActivity {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/widgets.dart', library: 'package:flutter/widgets.dart',
className: '$ScrollActivity', className: '$ScrollActivity',
object: this, object: this,
...@@ -150,7 +150,7 @@ abstract class ScrollActivity { ...@@ -150,7 +150,7 @@ abstract class ScrollActivity {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_isDisposed = true; _isDisposed = true;
...@@ -265,7 +265,7 @@ class ScrollDragController implements Drag { ...@@ -265,7 +265,7 @@ class ScrollDragController implements Drag {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/widgets.dart', library: 'package:flutter/widgets.dart',
className: '$ScrollDragController', className: '$ScrollDragController',
object: this, object: this,
...@@ -450,7 +450,7 @@ class ScrollDragController implements Drag { ...@@ -450,7 +450,7 @@ class ScrollDragController implements Drag {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_lastDetails = null; _lastDetails = null;
onDragCanceled?.call(); onDragCanceled?.call();
......
...@@ -335,7 +335,7 @@ class TextSelectionOverlay { ...@@ -335,7 +335,7 @@ class TextSelectionOverlay {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/widgets.dart', library: 'package:flutter/widgets.dart',
className: '$TextSelectionOverlay', className: '$TextSelectionOverlay',
object: this, object: this,
...@@ -597,7 +597,7 @@ class TextSelectionOverlay { ...@@ -597,7 +597,7 @@ class TextSelectionOverlay {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
_selectionOverlay.dispose(); _selectionOverlay.dispose();
renderObject.selectionStartInViewport.removeListener(_updateTextSelectionOverlayVisibilities); renderObject.selectionStartInViewport.removeListener(_updateTextSelectionOverlayVisibilities);
...@@ -974,7 +974,7 @@ class SelectionOverlay { ...@@ -974,7 +974,7 @@ class SelectionOverlay {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/widgets.dart', library: 'package:flutter/widgets.dart',
className: '$SelectionOverlay', className: '$SelectionOverlay',
object: this, object: this,
...@@ -1533,7 +1533,7 @@ class SelectionOverlay { ...@@ -1533,7 +1533,7 @@ class SelectionOverlay {
// TODO(polina-c): stop duplicating code across disposables // TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435 // https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
} }
hide(); hide();
_magnifierInfo.dispose(); _magnifierInfo.dispose();
......
...@@ -26,7 +26,7 @@ class PrintOverrideTestBinding extends AutomatedTestWidgetsFlutterBinding { ...@@ -26,7 +26,7 @@ class PrintOverrideTestBinding extends AutomatedTestWidgetsFlutterBinding {
} }
void main() { void main() {
final MemoryAllocations ma = MemoryAllocations.instance; final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance;
PrintOverrideTestBinding(); PrintOverrideTestBinding();
......
...@@ -9,7 +9,7 @@ import 'package:flutter/rendering.dart'; ...@@ -9,7 +9,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
final MemoryAllocations ma = MemoryAllocations.instance; final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance;
setUp(() { setUp(() {
assert(!ma.hasListeners); assert(!ma.hasListeners);
......
...@@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
int _disposals = 0; int _disposals = 0;
void main() { void main() {
final MemoryAllocations ma = MemoryAllocations.instance; final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance;
test('Publishers dispatch events in debug mode', () async { test('Publishers dispatch events in debug mode', () async {
void listener(ObjectEvent event) { void listener(ObjectEvent event) {
......
...@@ -652,14 +652,14 @@ void main() { ...@@ -652,14 +652,14 @@ void main() {
events.add(event); events.add(event);
} }
} }
MemoryAllocations.instance.addListener(listener); FlutterMemoryAllocations.instance.addListener(listener);
await createAndDisposeRoute(); await createAndDisposeRoute();
expect(events, hasLength(2)); expect(events, hasLength(2));
expect(events.first, isA<ObjectCreated>()); expect(events.first, isA<ObjectCreated>());
expect(events.last, isA<ObjectDisposed>()); 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 { testWidgets('Route didAdd and dispose in same frame work', (WidgetTester tester) async {
......
...@@ -8,7 +8,7 @@ import 'package:flutter/foundation.dart'; ...@@ -8,7 +8,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
final MemoryAllocations ma = MemoryAllocations.instance; final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance;
setUp(() { setUp(() {
assert(!ma.hasListeners); assert(!ma.hasListeners);
...@@ -20,7 +20,7 @@ void main() { ...@@ -20,7 +20,7 @@ void main() {
}); });
testWidgets( testWidgets(
'$MemoryAllocations is noop when kFlutterMemoryAllocationsEnabled is false.', '$FlutterMemoryAllocations is noop when kFlutterMemoryAllocationsEnabled is false.',
(WidgetTester tester) async { (WidgetTester tester) async {
ObjectEvent? receivedEvent; ObjectEvent? receivedEvent;
ObjectEvent listener(ObjectEvent event) => receivedEvent = event; ObjectEvent listener(ObjectEvent event) => receivedEvent = event;
......
...@@ -9,14 +9,14 @@ import 'package:flutter/rendering.dart'; ...@@ -9,14 +9,14 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
final MemoryAllocations ma = MemoryAllocations.instance; final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance;
setUp(() { setUp(() {
assert(!ma.hasListeners); assert(!ma.hasListeners);
}); });
testWidgets( testWidgets(
'$MemoryAllocations is noop when kFlutterMemoryAllocationsEnabled is false.', '$FlutterMemoryAllocations is noop when kFlutterMemoryAllocationsEnabled is false.',
(WidgetTester tester) async { (WidgetTester tester) async {
ObjectEvent? receivedEvent; ObjectEvent? receivedEvent;
ObjectEvent listener(ObjectEvent event) => receivedEvent = event; ObjectEvent listener(ObjectEvent event) => receivedEvent = event;
......
...@@ -7,14 +7,14 @@ import 'package:flutter/widgets.dart'; ...@@ -7,14 +7,14 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
final MemoryAllocations ma = MemoryAllocations.instance; final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance;
setUp(() { setUp(() {
assert(!ma.hasListeners); assert(!ma.hasListeners);
}); });
testWidgets( testWidgets(
'$MemoryAllocations is noop when kFlutterMemoryAllocationsEnabled is false.', '$FlutterMemoryAllocations is noop when kFlutterMemoryAllocationsEnabled is false.',
(WidgetTester tester) async { (WidgetTester tester) async {
ObjectEvent? receivedEvent; ObjectEvent? receivedEvent;
ObjectEvent listener(ObjectEvent event) => receivedEvent = event; 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