getWallets function
Retrieves the user's wallets.
Throws an UserWalletsFetchFailure if the wallets are null or if the method fails
Implementation
Future<List<Wallet>> getWallets() async {
try {
final response = await _platform.getWallets();
if (response == null) {
throw Exception("Unable to get the user's wallets.");
}
final wallets = response['wallets'] as List<dynamic>;
return wallets
.map<Wallet>(
(wallet) => Wallet.fromJson(Map<String, dynamic>.from(json.decode(json.encode(wallet)))),
)
.toList();
} catch (error, stackTrace) {
Error.throwWithStackTrace(UserWalletsFetchFailure(error), stackTrace);
}
}