saveUserData method

Future<void> saveUserData(
  1. dynamic context, {
  2. dynamic postJson,
})

Implementation

Future<void> saveUserData(context, {postJson}) async {
  try {
    userLoad = true;
    notifyListeners();
    Uri url = Uri.parse("${baseurl}User/SaveUserDetails");
    final response = await http.post(url,
        body: jsonEncode(postJson),
        headers: headers);
    if (response.statusCode == 200) {
      final decodedData = json.decode(response.body);
      final status = decodedData["status"];
      final message = decodedData["message"];
      Fluttertoast.showToast(
          msg: message,
          backgroundColor: status == true ? Colors.green : Colors.red);
    }
    userLoad = false;
    notifyListeners();
  } on Exception {
    userLoad = false;
    notifyListeners();
  }
}