count method
Implementation
Future<bool> count() async {
if (waitForInternet && !await con.hasInternetAccess) {
await con.onStatusChange
.where((event) => event == InternetStatus.connected)
.first;
}
try {
var id = await getID() ?? "";
var resp = await post(baseUrl.resolveUri(Uri(path: "/count")),
headers: {
"X-API-Key": apiKey,
"content-type": "application/json",
},
body: const JsonEncoder()
.convert({"id": id, "platform": plat}));
if (resp.statusCode == 201) {
Map<String, String> rt = const JsonDecoder().convert(resp.body);
if (rt["id"] != id) {
setID(rt["id"]!);
}
}
return resp.statusCode == 201;
} catch (e, stack) {
if (onError != null) onError!(e, stack);
return false;
}
}