OtpVerifyFunction method

Future OtpVerifyFunction({
  1. dynamic mobNum,
  2. dynamic deviceid,
  3. dynamic otp,
  4. dynamic fcmkey,
})

Implementation

Future OtpVerifyFunction({
  mobNum,
  deviceid,
  otp,
  fcmkey,
}) async {
  final response = await http.post(
    Uri.parse('${SDK_BASE_URL}claim_adminpanel/claim_api/match_otp'),
    body: {
      "device_id": deviceid,
      "mobile_no": mobNum,
      "otp": otp,
      "fcmkey": fcmkey,
      "source": Platform.isAndroid ? 1.toString() : 2.toString()
    },
  );
  var decodedResponse = json.decode(response.body);

  if (response.statusCode == 200) {
    Get.back();
  }
  if (decodedResponse['status'] == true) {
    SharedPreferences _prefs = await SharedPreferences.getInstance();
    _prefs.setString('currentUserToken', decodedResponse['access_token']);
    currentUserToken = _prefs.getString('currentUserToken');

    Get.offAll(HomePage());
  } else {
    Fluttertoast.showToast(
        msg: "${decodedResponse['message']}",
        fontSize: 11.sp,
        gravity: ToastGravity.CENTER,
        toastLength: Toast.LENGTH_SHORT);
  }
}