onBuild function
Registers a callback to be called on every build.
The callback is called when the builder function executes, which happens on every reactive update.
This is useful for composables that need to react to BuildContext changes, such as TickerMode tracking.
Note: This is an advanced API intended for composable authors (used internally by useSingleTickerProvider and useContextRef). Most application code should not need to call this directly.
Must be called within the setup() method of CompositionWidget or CompositionBuilder.
Implementation
void onBuild(void Function(BuildContext) callback) {
final context = getCurrentSetupContext();
assert(
context != null,
'onBuild must be called within setup() of CompositionWidget or '
'CompositionBuilder',
);
context?.addBuildCallback(callback);
}