debugPrintTransientCallbackRegistrationStack method

void debugPrintTransientCallbackRegistrationStack ()

Prints the stack for where the current transient callback was registered.

A transient frame callback is one that was registered with scheduleFrameCallback.

When called in debug more and in the context of a transient callback, this function prints the stack trace from where the current transient callback was registered (i.e. where it first called scheduleFrameCallback).

When called in debug mode in other contexts, it prints a message saying that this function was not called in the context a transient callback.

In release mode, this function does nothing.

To call this function, use the following code:

  SchedulerBinding.debugPrintTransientCallbackRegistrationStack();

Implementation

static void debugPrintTransientCallbackRegistrationStack() {
  assert(() {
    if (_FrameCallbackEntry.debugCurrentCallbackStack != null) {
      debugPrint('When the current transient callback was registered, this was the stack:');
      debugPrint(
        FlutterError.defaultStackFilter(
          _FrameCallbackEntry.debugCurrentCallbackStack.toString().trimRight().split('\n')
        ).join('\n')
      );
    } else {
      debugPrint('No transient callback is currently executing.');
    }
    return true;
  }());
}