createBankInformation function

Future<BankInformation> createBankInformation(
  1. String bankName,
  2. String accountNumber,
  3. String isPublished
)

Implementation

Future<BankInformation> createBankInformation(
  String bankName,
  String accountNumber,
  String isPublished,
) async {
  HttpOverrides.global = new MyHttpOverrides();
  final response = await http.post(
    // Uri.parse('https://172.30.1.10:45455/api/BankInformationModels'),
    Uri.parse('https://192.168.1.106:45455/api/BankInformationModels'),

    headers: <String, String>{
      'Content-Type': 'application/json; charset=UTF-8',
    },
    body: jsonEncode(<String, String>{
      'bankName': bankName,
      'accountNumber': accountNumber,
      'isPublished': isPublished,
    }),
  );

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