FlutterMemoryAllocations class

An interface for listening to object lifecycle events.

If kFlutterMemoryAllocationsEnabled is true, FlutterMemoryAllocations listens to creation and disposal events for disposable objects in Flutter Framework. 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 of the class, if memory allocations are disabled.

The class is optimized for massive event flow and small number of added or removed listeners.


hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Return true if there are listeners.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited


addListener(ObjectEventListener listener) → void
Register a listener that is called every time an object event is dispatched.
dispatchObjectCreated({required String library, required String className, required Object object}) → void
Create ObjectCreated and invoke dispatchObjectEvent if there are listeners.
dispatchObjectDisposed({required Object object}) → void
Create ObjectDisposed and invoke dispatchObjectEvent if there are listeners.
dispatchObjectEvent(ObjectEvent event) → void
Dispatch a new object event to listeners.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
removeListener(ObjectEventListener listener) → void
Stop calling the given listener every time an object event is dispatched.
toString() String
A string representation of this object.


operator ==(Object other) bool
The equality operator.

Static Properties

instance FlutterMemoryAllocations
The shared instance of FlutterMemoryAllocations.