import 'dart:convert'; import 'package:http/http.dart' as http; class UserRegistrationSheet { String firstName; String lastName; String email; String password; String passwordConfirmation; bool termsAccepted; DateTime birthdate; String gender; String country; String city; String lang; int weight; int height; int chestCircumference; int waistCircumference; int hipCircumference; int bloodPressureUp; int bloodPressureDown; bool hasHypo = false; bool hasHyper = false; String aboutAllergy = ''; String aboutTakingPils = ''; String aboutSportHobbies = ''; String favoriteFoods = ''; String unfavoriteFoods = ''; String additionalInfo = ''; UserRegistrationSheet({ required this.firstName, required this.lastName, required this.email, required this.password, required this.passwordConfirmation, required this.termsAccepted, required this.birthdate, required this.gender, required this.country, required this.city, required this.lang, required this.weight, required this.height, required this.chestCircumference, required this.waistCircumference, required this.hipCircumference, required this.bloodPressureUp, required this.bloodPressureDown, required this.hasHypo, required this.hasHyper, required this.aboutAllergy, required this.aboutTakingPils, required this.aboutSportHobbies, required this.favoriteFoods, required this.unfavoriteFoods, required this.additionalInfo, }); Map toJson() { return { 'first_name': firstName, 'last_name': lastName, 'email': email, 'password': password, 'password_confirmation': passwordConfirmation, 'terms': termsAccepted, 'birthdate': birthdate.toIso8601String(), 'gender': gender, 'country': country, 'city': city, 'lang': lang, 'weight': weight, 'height': height, 'chest_circumference': chestCircumference, 'waist_circumference': waistCircumference, 'hip_circumference': hipCircumference, 'blood_pressure_up': bloodPressureUp, 'blood_pressure_down': bloodPressureDown, 'has_hypo': hasHypo, 'has_hyper': hasHyper, 'about_alergy': aboutAllergy, 'about_taking_pils': aboutTakingPils, 'about_sport_hobbies': aboutSportHobbies, 'favorite_foods': favoriteFoods, 'unfavorite_foods': unfavoriteFoods, 'additional_info': additionalInfo, }; } Future sendJson(Uri url) async { final response = await http.post( url, headers: {'Content-Type': 'application/json'}, body: jsonEncode(toJson()), ); if (response.statusCode != 200) { throw Exception('Failed to send data'); } } }