isauthenticated method
dynamic
isauthenticated(
- dynamic context, {
- required dynamic phone,
- required ConfigurationModel tap,
Implementation
isauthenticated(context,
{required phone, required ConfigurationModel tap}) async {
try {
_loader = true;
notifyListeners();
//log("start $phone");
Uri url = Uri.parse("${baseurl}Authentication/AuthenticateUser");
final response = await http.post(url,
headers: headers, body: json.encode({"phone": phone}));
//log(response.body.toString());
if (response.statusCode == 200) {
final decodeddata = json.decode(response.body);
final status = decodeddata['status'];
if (status == true) {
var isubscribed = decodeddata['data']['user']['isSubscribed'];
if (isubscribed == "Yes") {
var finalcount = decodeddata['data']['user']['scansLimit'];
var totalscan = decodeddata['data']['totalScansCount'];
if (finalcount <= 0) {
showWarningDialog(
context,
titlestye: tap.alerttitlestyle,
messagestyle: tap.alertmessageStyle,
title: totalscan > 100 ? "Warning" : "Trial Expired",
message: totalscan > 100
? "You have used all scans please subscribe again to use new scans"
: "Your trial version has expired. Please upgrade to the full version to continue using the app.",
);
} else {
Provider.of<MeasurementModel>(context, listen: false)
.startStopButtonClicked(measurementDuration: tap.duration);
}
}
} else {
showWarningDialog(context,
title: "Warning",
titlestye: tap.alerttitlestyle,
messagestyle: tap.alertmessageStyle,
message:
"You are not opted to our services please register to use our services");
}
}
} catch (e) {
// log(e.toString());
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text(
"Something went wrong",
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 12, color: Colors.white),
)));
}
//log("end");
_loader = false;
notifyListeners();
}