UpdateMembers method

Future UpdateMembers({
  1. dynamic name,
  2. dynamic age,
  3. dynamic gender,
  4. dynamic relation,
  5. dynamic context,
  6. dynamic member_id,
})

Implementation

Future UpdateMembers(
    {name, age, gender, relation, context, member_id}) async {
  var decodedResponse;
  final ApiBody = {
    "name": "${name}",
    "age": "${age}",
    "gender": "${gender}",
    "relation": "${relation}",
    "member_id": member_id
  };
  try {
    Map data = ApiBody;
    var body = jsonEncode(data);

    final response = await http.post(
      Uri.parse('${WELLNESS_URL}api/diagnostic/create-member'),
      headers: {
        'Authorization': currentUserToken,
        "Content-Type": "application/json"
      },
      body: body,
    );
    decodedResponse = json.decode(response.body);
    if (decodedResponse['success'] == true) {
      await getcMemberList();
      await showDialog(
        barrierDismissible: false,
        context: context,
        builder: (BuildContext context) {
          return PinCodePopUp(
            messag: "${decodedResponse['message']}",
            image: '${LottiePath}Upload_Successful.json',
          );
        },
      );
    } else {
      await showDialog(
        barrierDismissible: false,
        context: context,
        builder: (BuildContext context) {
          return PinCodePopUp(
            messag: "${decodedResponse['message']}",
            image: '${LottiePath}Error.json',
          );
        },
      );
    }
  } catch (e) {
    ErrorListner(
        apiname: 'api/diagnostic/create-member',
        responsed: "${decodedResponse}",
        request: "${ApiBody}",
        app_error: '${e}');
  }
}