fetchBankInformation function

Future<List<BankInformation>> fetchBankInformation()

Implementation

Future<List<BankInformation>> fetchBankInformation() async {
  HttpOverrides.global = new MyHttpOverrides();
  // final response = await http
  //    .get(Uri.parse('https://172.30.1.10:45455/api/BankInformationModels'));
  final response = await http
      .get(Uri.parse('https://192.168.1.106:45455/api/BankInformationModels'));
  List<BankInformation> bankInformation = [];

  if (response.statusCode == 200) {
    // If the server did return a 200 OK response,
    // then parse the JSON.
    var bankInformationJson = json.decode(response.body);
    for (var bankInformationJson in bankInformationJson) {
      bankInformation.add(BankInformation.fromJson(bankInformationJson));
    }
    return bankInformation;
  } else {
    // If the server did not return a 200 OK response,
    // then throw an exception.
    throw Exception('Failed to load Service');
  }
}