getLedgerIndex static method
This asynchronous function retrieves the ledger index from an XRPL server. It provides an optional defaultLedgerOffset to adjust the index.
Implementation
static Future<int> getLedgerIndex(XRPLRpc client,
{int defaultLedgerOffset = 20}) async {
/// Fetch ledger data from the XRPL server.
final LedgerData ledgerData = await client.request(RPCLedger());
/// Calculate the ledger index by adding the default offset.
final int ledgerIndex = ledgerData.ledgerIndex + defaultLedgerOffset;
/// Return the calculated ledger index.
return ledgerIndex;
}