sendBulkStatements static method
Sends a batch list of xAPI statements in a single bulk request to the configured LRS.
Returns the http.Response from the LRS, or null if uninitialized or if an error occurs.
Implementation
static Future<http.Response?> sendBulkStatements(
List<Statement> statements,
) async {
if (!_lrs.ensureInitialised()) {
AppLogger.log("LRS NOT INITALISED!");
return null;
}
AppLogger.log("Sending statement...");
return _lrs
.sendStatements(statements)
.then((response) {
if (response != null) {
AppLogger.log("Statement sent. Status: ${response.statusCode}");
AppLogger.log("Response body: ${response.body}");
} else {
AppLogger.log("No response returned from LRS.");
}
return response;
})
.catchError((e) {
AppLogger.log("Error sending statement: $e");
return null;
});
}