initialize method
Implementation
@override
Future<void> initialize(
BuildContext context, {
IFastErrorReporter? errorReporter,
}) async {
// Check if there are any callbacks provided. If none, we do not need
// to proceed.
if (callbacks == null || callbacks!.isEmpty) return;
_logger.debug('Initializing...');
// Execute all the provided callbacks.
for (final callback in callbacks!) {
try {
_logger.debug('Executing callback: $callback');
await callback(context); // Waiting for the callback to complete.
} catch (error, stackTrace) {
_logger.error('Failed to execute callback: $error');
if (errorReporter != null) {
errorReporter.recordError(error, stackTrace);
}
rethrow;
}
}
_logger.debug('Initialized');
}