verifyCode method
Implementation
Future<VerifyCodeStatus> verifyCode(String url) async {
VerifyCodeStatus status = VerifyCodeStatus.error;
try {
final res = await http.post(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json',
},
).catchError((e) {
if (kDebugMode) {
print("verifyCode failed: $e \n $url");
}
});
// print("XXXX ${res?.statusCode} - ${res.body}");
if (res.statusCode == 200) {
// print("verifyCode body ${res.body}");
status = VerifyCodeStatus.notExitst;
try {
status = int.parse(res.body) == 1 ? VerifyCodeStatus.done : VerifyCodeStatus.expired;
} catch (e) {
if (kDebugMode) {
print("parse error: $e");
}
}
return status;
}
} catch (e) {
if (kDebugMode) {
print('verifyCode $e');
}
}
return status;
}