invokeAsync<T> static method
- T? callback,
- List getArgs()
Invokes an async callback safely.
Unlike the synchronous invoke, this method awaits the callback completion but still catches and logs any errors.
Returns a Future that completes when the callback finishes or errors.
Implementation
static Future<void> invokeAsync<T>(
T? callback,
List<dynamic> Function() getArgs,
) async {
if (callback == null) return;
try {
final result = Function.apply(callback as Function, getArgs());
// If the callback returns a Future, await it
if (result is Future) {
await result;
}
} catch (e) {
// Silently ignore async callback errors to prevent user callback bugs
// from crashing the chart. In debug mode, use breakpoints to inspect
// callback failures.
}
}