updateVendorAddress function

Future<VendorAddress> updateVendorAddress(
  1. int? vendorAddressId,
  2. String vendorAddress,
  3. String country,
  4. String state,
  5. String city,
  6. String postCode,
  7. String businessLatitude,
  8. String businessLongitude,
  9. String isPublished,
)

Implementation

Future<VendorAddress> updateVendorAddress(
    int? vendorAddressId,
    String vendorAddress,
    String country,
    String state,
    String city,
    String postCode,
    String businessLatitude,
    String businessLongitude,
    String isPublished) async {
  HttpOverrides.global = new MyHttpOverrides();
  final response = await http.put(
    // Uri.parse(
    //     'https://172.30.1.10:45455/api/VendorAddressModels/$vendorAddressId'),
    Uri.parse(
        'https://192.168.1.106:45455/api/VendorAddressModels/$vendorAddressId'),

    headers: <String, String>{
      'Content-Type': 'application/json; charset=UTF-8',
    },
    body: jsonEncode(<String, String>{
      'vendorAddressId': vendorAddressId.toString(),
      'vendorAddress': vendorAddress,
      'country': country,
      'state': state,
      'city': city,
      'postCode': postCode,
      'businessLatitude': businessLatitude,
      'businessLongitude': businessLongitude,
      'isPublished': isPublished,
    }),
  );

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