MembersCRUD method

Future MembersCRUD({
  1. dynamic crudoperation,
  2. dynamic memberid,
  3. dynamic name,
  4. dynamic age,
  5. dynamic gender,
  6. dynamic relation,
  7. dynamic context,
  8. dynamic popup,
})

Implementation

Future MembersCRUD(
    {crudoperation,
    memberid,
    name,
    age,
    gender,
    relation,
    context,
    popup}) async {
  var decodedResponse;
  final apibody = {
    'post_type': '${crudoperation}',
    'member_id': '${memberid}',
    'patient_type': 'member',
    'patient_name': '${name}',
    'age': '${age}',
    'gender': '${gender}',
    'relationship': '${relation}'
  };
  try {
    final response = await http.post(
      Uri.parse('${SDK_BASE_URL}medicine_api/fetch_patient_details'),
      headers: {'Authorization': SignUpController.currentUserToken},
      body: apibody,
    );
    decodedResponse = json.decode(response.body);
    if (decodedResponse['status'] == 200) {
      // Get.to(AddressDisplay());
      Loading = 'end';
      if (popup == false) {
        showDialog(
          barrierDismissible: false,
          context: context,
          builder: (BuildContext context) {
            return PinCodePopUp(
              messag: "${decodedResponse['message']}",
              image: '${LottiePath}Upload_Successful.json',
            );
          },
        );
      } else {
        Get.back();
        showDialog(
          barrierDismissible: false,
          context: context,
          builder: (BuildContext context) {
            return PinCodePopUp(
              messag: "${decodedResponse['message']}",
              image: '${LottiePath}Upload_Successful.json',
            );
          },
        );
      }
    } else {
      Loading = 'end';
      if (popup == false) {
        showDialog(
          context: context,
          barrierDismissible: false,
          builder: (BuildContext context) {
            return PinCodePopUp(
              messag: "${decodedResponse['message']}",
              image: '${LottiePath}Error.json',
            );
          },
        );
      } else {
        Get.back();
        showDialog(
          context: context,
          barrierDismissible: false,
          builder: (BuildContext context) {
            return PinCodePopUp(
              messag: "${decodedResponse['message']}",
              image: '${LottiePath}Error.json',
            );
          },
        );
      }
    }
    await ClearAllDignosticsArray();
    (context as Element).reassemble();
  } catch (e) {
    errorListner(
        apiname: 'medicine_api/fetch_patient_details',
        responsed: "${decodedResponse}",
        request: '${apibody}',
        app_error: '${e}');
  }
}