memoryEvents function
Invokes callback
and collects
events dispatched to FlutterMemoryAllocations.instance for type
.
Implementation
Future<List<ObjectEvent>> memoryEvents(
FutureOr<void> Function() callback,
Type type,
) async {
final events = <ObjectEvent>[];
void listener(ObjectEvent event) {
if (event.object.runtimeType == type) {
events.add(event);
}
}
FlutterMemoryAllocations.instance.addListener(listener);
await callback();
FlutterMemoryAllocations.instance.removeListener(listener);
return events;
}