createUserOrganization2 function

Future<UserOrganization> createUserOrganization2(
  1. String companyName,
  2. int companyRocNumber,
  3. String address,
  4. String country,
  5. String state,
  6. String city,
  7. int postalCode,
  8. String emailAddress,
  9. String password,
  10. String contactNumber,
)

Implementation

Future<UserOrganization> createUserOrganization2(
    String companyName,
    int companyRocNumber,
    String address,
    String country,
    String state,
    String city,
    int postalCode,
    String emailAddress,
    String password,
    String contactNumber) async {
  HttpOverrides.global = new MyHttpOverrides();
  // final response = await http.post(
  //   Uri.parse('https://172.30.1.33:45455/api/UserOrganizationModels'),
  final response = await http.post(
    Uri.parse('https://192.168.1.106:45455/api/UserOrganizationModels'),
    headers: <String, String>{
      'Content-Type': 'application/json; charset=UTF-8',
    },
    body: jsonEncode(<String, String>{
      'companyName': companyName,
      'companyRocNumber': companyRocNumber.toString(),
      'address': address,
      'country': country,
      'state': state,
      'city': city,
      'postalCode': postalCode.toString(),
      'emailAddress': emailAddress,
      'password': password,
      'contactNumber': contactNumber,
    }),
  );

  if (response.statusCode == 201) {
    // If the server did return a 201 CREATED response,
    // then parse the JSON.
    return UserOrganization.fromJson(jsonDecode(response.body));
  } else {
    // If the server did not return a 201 CREATED response,
    // then throw an exception.
    throw Exception('Failed to create user.');
  }
}