getAccountForToken method

Future<Account> getAccountForToken(
  1. String accountName, {
  2. required String token,
})

Returns the token for the account with the given name. If account not found, returns an Account with default fields (like Account.empty, except the name and symbol fields are set). If token not found, throws an Exception

Implementation

Future<Account> getAccountForToken(
  String accountName, {
  required String token,
}) async {
  final queryArgs = <String, String>{'hive': '1', 'token': token};
  final uri = Uri.https(_baseUrl, '/@$accountName', queryArgs);
  final bodyJson = await _fetchData(uri) as Map<String, dynamic>;
  return Account.fromJson(bodyJson[token] as Map<String, dynamic>);
}