getAccountBalance function
Future<double?>
getAccountBalance({
- String? uuid,
- String? currency,
- Client? client,
- required Credential credential,
- bool isSandbox = false,
Gets the balance of a single account for the current user.
This function can get the balance by either the account UUID or the currency.
uuid - The UUID of the account.
currency - The currency of the account.
credential - The user's API credentials.
isSandbox - Whether to use the sandbox environment.
Returns the available balance of the account as a double, or null if the account is not found.
Implementation
Future<double?> getAccountBalance(
{String? uuid,
String? currency,
http.Client? client,
required Credential credential,
bool isSandbox = false}) async {
if (uuid != null) {
Account? account = await getAccount(
uuid: uuid,
client: client,
credential: credential,
isSandbox: isSandbox);
return account?.availableBalance;
}
if (currency != null) {
Account? account = await getAccountByCurrency(currency,
client: client, credential: credential, isSandbox: isSandbox);
return account?.availableBalance;
}
return null;
}