checkAddressIdena method
Implementation
Future<bool> checkAddressIdena(String address) async {
bool check = false;
HttpClient httpClient = new HttpClient();
Completer<bool> _completer = new Completer<bool>();
try {
HttpClientRequest request = await httpClient
.getUrl(Uri.parse("https://api.idena.io/api/Address/" + address));
request.headers.set('content-type', 'application/json');
HttpClientResponse response = await request.close();
if (response.statusCode == 200) {
String reply = await response.transform(utf8.decoder).join();
ApiGetAddressResponse apiGetAddressResponse =
apiGetAddressResponseFromJson(reply);
if (apiGetAddressResponse != null &&
apiGetAddressResponse.result != null &&
apiGetAddressResponse.result.address != null &&
apiGetAddressResponse.result.address.toUpperCase() ==
address.toUpperCase()) {
check = true;
}
}
} catch (e) {
print("exception : " + e.toString());
} finally {
httpClient.close();
}
_completer.complete(check);
return _completer.future;
}