send static method
Sends an individual xAPI statement 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?> send(Statement statement) async {
if (!_lrs.ensureInitialised()) {
AppLogger.log("LRS NOT INITALISED!");
return null;
}
AppLogger.log("Sending statement...");
return _lrs
.sendStatement(statement)
.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;
});
}